diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp | 10 | ||||
-rw-r--r-- | llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll | 46 |
2 files changed, 52 insertions, 4 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp index 279a8218b1c..f296d80dbf5 100644 --- a/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp +++ b/llvm/lib/Target/SystemZ/SystemZTargetTransformInfo.cpp @@ -748,10 +748,12 @@ int SystemZTTIImpl::getCastInstrCost(unsigned Opcode, Type *Dst, Type *Src, else { // Scalar assert (!Dst->isVectorTy()); - if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP) - return (SrcScalarBits >= 32 - ? 1 - : SrcScalarBits > 1 ? 2 /*i8/i16 extend*/ : 5 /*branch seq.*/); + if (Opcode == Instruction::SIToFP || Opcode == Instruction::UIToFP) { + if (SrcScalarBits >= 32 || + (I != nullptr && isa<LoadInst>(I->getOperand(0)))) + return 1; + return SrcScalarBits > 1 ? 2 /*i8/i16 extend*/ : 5 /*branch seq.*/; + } if ((Opcode == Instruction::ZExt || Opcode == Instruction::SExt) && Src->isIntegerTy(1)) { diff --git a/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll b/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll index 4ea5a5033d7..20feefb8025 100644 --- a/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll +++ b/llvm/test/Analysis/CostModel/SystemZ/fp-cast.ll @@ -539,3 +539,49 @@ define void @uitofp() { ret void; } + +define void @sitofp_extload(i16 *%src16, i8 *%src8) { + %ld16 = load i16, i16 *%src16 + %v6 = sitofp i16 %ld16 to fp128 + %v7 = sitofp i16 %ld16 to double + %v8 = sitofp i16 %ld16 to float + + %ld8 = load i8, i8 *%src8 + %v9 = sitofp i8 %ld8 to fp128 + %v10 = sitofp i8 %ld8 to double + %v11 = sitofp i8 %ld8 to float + +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %ld16 = load i16, i16* %src16 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v6 = sitofp i16 %ld16 to fp128 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v7 = sitofp i16 %ld16 to double +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v8 = sitofp i16 %ld16 to float +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %ld8 = load i8, i8* %src8 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v9 = sitofp i8 %ld8 to fp128 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v10 = sitofp i8 %ld8 to double +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v11 = sitofp i8 %ld8 to float + + ret void; +} + +define void @uitofp_extload(i16 *%src16, i8 *%src8) { + %ld16 = load i16, i16 *%src16 + %v6 = uitofp i16 %ld16 to fp128 + %v7 = uitofp i16 %ld16 to double + %v8 = uitofp i16 %ld16 to float + + %ld8 = load i8, i8 *%src8 + %v9 = uitofp i8 %ld8 to fp128 + %v10 = uitofp i8 %ld8 to double + %v11 = uitofp i8 %ld8 to float + +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %ld16 = load i16, i16* %src16 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v6 = uitofp i16 %ld16 to fp128 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v7 = uitofp i16 %ld16 to double +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v8 = uitofp i16 %ld16 to float +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %ld8 = load i8, i8* %src8 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v9 = uitofp i8 %ld8 to fp128 +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v10 = uitofp i8 %ld8 to double +; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %v11 = uitofp i8 %ld8 to float + + ret void; +} |