[PATCH] D78547: [TTI] getUserCost to return getCastInstrCost
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 21 02:39:57 PDT 2020
samparker created this revision.
samparker added reviewers: spatel, RKSimon, craig.topper.
Herald added a project: LLVM.
If the generic cost model, based on DataLayout, says that a cast is free then return zero. Otherwise we now return the cost provided by getCastInstrCost.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78547
Files:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/test/Analysis/CostModel/X86/size-cost.ll
Index: llvm/test/Analysis/CostModel/X86/size-cost.ll
===================================================================
--- llvm/test/Analysis/CostModel/X86/size-cost.ll
+++ llvm/test/Analysis/CostModel/X86/size-cost.ll
@@ -30,7 +30,7 @@
define i64 @bitcast_f64_i64(double %x) {
; CHECK-LABEL: 'bitcast_f64_i64'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = bitcast double %x to i64
+; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = bitcast double %x to i64
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %r
;
%r = bitcast double %x to i64
@@ -39,7 +39,7 @@
define double @bitcast_i64_f64(i64 %x) {
; CHECK-LABEL: 'bitcast_i64_f64'
-; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: %r = bitcast i64 %x to double
+; CHECK-NEXT: Cost Model: Found an estimated cost of 0 for instruction: %r = bitcast i64 %x to double
; CHECK-NEXT: Cost Model: Found an estimated cost of 1 for instruction: ret double %r
;
%r = bitcast i64 %x to double
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -846,14 +846,11 @@
case Instruction::IntToPtr:
case Instruction::PtrToInt:
case Instruction::Trunc:
- if (getCastInstrCost(Opcode, Ty, OpTy, I) == TTI::TCC_Free ||
- TargetTTI->getCastInstrCost(Opcode, Ty, OpTy, I) == TTI::TCC_Free)
- return TTI::TCC_Free;
- break;
case Instruction::BitCast:
- if (getCastInstrCost(Opcode, Ty, OpTy, I) == TTI::TCC_Free)
- return TTI::TCC_Free;
- break;
+ // Check if the operation is free according to the datalayout.
+ if (getCastInstrCost(Opcode, Ty, OpTy, I) == 0)
+ return 0;
+ return TargetTTI->getCastInstrCost(Opcode, Ty, OpTy, I);
case Instruction::FPExt:
case Instruction::SExt:
case Instruction::ZExt:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78547.258934.patch
Type: text/x-patch
Size: 2066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/ed82e963/attachment.bin>
More information about the llvm-commits
mailing list