forked from OSchip/llvm-project
[ARM] sext of a load is free
This teaches the cost model that the sext or zext of a load is going to be free. Differential Revision: https://reviews.llvm.org/D66006 llvm-svn: 368593
This commit is contained in:
parent
4c9c98f36b
commit
86876422ef
|
@ -167,6 +167,27 @@ int ARMTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src,
|
||||||
if (!SrcTy.isSimple() || !DstTy.isSimple())
|
if (!SrcTy.isSimple() || !DstTy.isSimple())
|
||||||
return BaseT::getCastInstrCost(Opcode, Dst, Src);
|
return BaseT::getCastInstrCost(Opcode, Dst, Src);
|
||||||
|
|
||||||
|
// The extend of a load is free
|
||||||
|
if (I && isa<LoadInst>(I->getOperand(0))) {
|
||||||
|
static const TypeConversionCostTblEntry LoadConversionTbl[] = {
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i32, MVT::i16, 0},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i32, MVT::i16, 0},
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i32, MVT::i8, 0},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i32, MVT::i8, 0},
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i16, MVT::i8, 0},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i16, MVT::i8, 0},
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i64, MVT::i32, 1},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i64, MVT::i32, 1},
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i64, MVT::i16, 1},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i64, MVT::i16, 1},
|
||||||
|
{ISD::SIGN_EXTEND, MVT::i64, MVT::i8, 1},
|
||||||
|
{ISD::ZERO_EXTEND, MVT::i64, MVT::i8, 1},
|
||||||
|
};
|
||||||
|
if (const auto *Entry = ConvertCostTableLookup(
|
||||||
|
LoadConversionTbl, ISD, DstTy.getSimpleVT(), SrcTy.getSimpleVT()))
|
||||||
|
return Entry->Cost;
|
||||||
|
}
|
||||||
|
|
||||||
// Some arithmetic, load and store operations have specific instructions
|
// Some arithmetic, load and store operations have specific instructions
|
||||||
// to cast up/down their types automatically at no extra cost.
|
// to cast up/down their types automatically at no extra cost.
|
||||||
// TODO: Get these tables to know at least what the related operations are.
|
// TODO: Get these tables to know at least what the related operations are.
|
||||||
|
|
|
@ -814,15 +814,15 @@ define i32 @load_extends() {
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i16 = load <2 x i16>, <2 x i16>* undef
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i16 = load <2 x i16>, <2 x i16>* undef
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv4i16 = load <4 x i16>, <4 x i16>* undef
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv4i16 = load <4 x i16>, <4 x i16>* undef
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i32 = load <2 x i32>, <2 x i32>* undef
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i32 = load <2 x i32>, <2 x i32>* undef
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r0 = sext i8 %loadi8 to i16
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r0 = sext i8 %loadi8 to i16
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r1 = zext i8 %loadi8 to i16
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r1 = zext i8 %loadi8 to i16
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r2 = sext i8 %loadi8 to i32
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r2 = sext i8 %loadi8 to i32
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r3 = zext i8 %loadi8 to i32
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r3 = zext i8 %loadi8 to i32
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r4 = sext i8 %loadi8 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r4 = sext i8 %loadi8 to i64
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r5 = zext i8 %loadi8 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r5 = zext i8 %loadi8 to i64
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r6 = sext i16 %loadi16 to i32
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r6 = sext i16 %loadi16 to i32
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r7 = zext i16 %loadi16 to i32
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r7 = zext i16 %loadi16 to i32
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r8 = sext i16 %loadi16 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r8 = sext i16 %loadi16 to i64
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r9 = zext i16 %loadi16 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r9 = zext i16 %loadi16 to i64
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r10 = sext i32 %loadi32 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r10 = sext i32 %loadi32 to i64
|
||||||
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r11 = zext i32 %loadi32 to i64
|
; CHECK-NEON-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r11 = zext i32 %loadi32 to i64
|
||||||
|
@ -850,15 +850,15 @@ define i32 @load_extends() {
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i16 = load <2 x i16>, <2 x i16>* undef
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i16 = load <2 x i16>, <2 x i16>* undef
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv4i16 = load <4 x i16>, <4 x i16>* undef
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv4i16 = load <4 x i16>, <4 x i16>* undef
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i32 = load <2 x i32>, <2 x i32>* undef
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %loadv2i32 = load <2 x i32>, <2 x i32>* undef
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r0 = sext i8 %loadi8 to i16
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r0 = sext i8 %loadi8 to i16
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r1 = zext i8 %loadi8 to i16
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r1 = zext i8 %loadi8 to i16
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r2 = sext i8 %loadi8 to i32
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r2 = sext i8 %loadi8 to i32
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r3 = zext i8 %loadi8 to i32
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r3 = zext i8 %loadi8 to i32
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r4 = sext i8 %loadi8 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r4 = sext i8 %loadi8 to i64
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r5 = zext i8 %loadi8 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r5 = zext i8 %loadi8 to i64
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r6 = sext i16 %loadi16 to i32
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r6 = sext i16 %loadi16 to i32
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r7 = zext i16 %loadi16 to i32
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r7 = zext i16 %loadi16 to i32
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 2 for instruction: %r8 = sext i16 %loadi16 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r8 = sext i16 %loadi16 to i64
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r9 = zext i16 %loadi16 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r9 = zext i16 %loadi16 to i64
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r10 = sext i32 %loadi32 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r10 = sext i32 %loadi32 to i64
|
||||||
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r11 = zext i32 %loadi32 to i64
|
; CHECK-MVE-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r11 = zext i32 %loadi32 to i64
|
||||||
|
|
Loading…
Reference in New Issue