[PATCH] D78552: [TTI] Use getCastInstrCost for getUserCost Exts
Sam Parker via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 21 03:44:57 PDT 2020
samparker created this revision.
samparker added reviewers: uweigand, spatel, RKSimon.
Herald added a project: LLVM.
samparker added a parent revision: D78547: [TTI] getUserCost to return getCastInstrCost.
First query whether an implementation believes an instruction is free via getExtCost and otherwise return getCastInstrCost.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D78552
Files:
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/test/Analysis/CostModel/SystemZ/ext-of-icmp-cost.ll
Index: llvm/test/Analysis/CostModel/SystemZ/ext-of-icmp-cost.ll
===================================================================
--- llvm/test/Analysis/CostModel/SystemZ/ext-of-icmp-cost.ll
+++ llvm/test/Analysis/CostModel/SystemZ/ext-of-icmp-cost.ll
@@ -7,7 +7,7 @@
define i64 @fun1(i64 %v) {
; CHECK-LABEL: 'fun1'
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %cmp = icmp eq i64 %v, 0
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %z = zext i1 %cmp to i64
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %z = zext i1 %cmp to i64
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %z
%cmp = icmp eq i64 %v, 0
%z = zext i1 %cmp to i64
@@ -17,7 +17,7 @@
define i64 @fun2(i64 %v) {
; CHECK-LABEL: 'fun2'
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %cmp = icmp eq i64 %v, 0
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %z = sext i1 %cmp to i64
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %z = sext i1 %cmp to i64
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %z
%cmp = icmp eq i64 %v, 0
%z = sext i1 %cmp to i64
@@ -46,7 +46,7 @@
define i64 @fun5(i1 %v) {
; CHECK-LABEL: 'fun5'
-; CHECK: Cost Model: Found an estimated cost of 1 for instruction: %z = zext i1 %v to i64
+; CHECK: Cost Model: Found an estimated cost of 2 for instruction: %z = zext i1 %v to i64
; CHECK: Cost Model: Found an estimated cost of 1 for instruction: ret i64 %z
%z = zext i1 %v to i64
ret i64 %z
Index: llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
+++ llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -854,9 +854,9 @@
case Instruction::FPExt:
case Instruction::SExt:
case Instruction::ZExt:
- if (TargetTTI->getExtCost(I, Operands.back()) == TTI::TCC_Free)
- return TTI::TCC_Free;
- break;
+ if (I && TargetTTI->getExtCost(I, Operands.back()) == 0)
+ return 0;
+ return TargetTTI->getCastInstrCost(Opcode, Ty, OpTy, I);
}
// By default, just classify everything as 'basic'.
return TTI::TCC_Basic;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78552.258953.patch
Type: text/x-patch
Size: 2316 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/0557a73d/attachment.bin>
More information about the llvm-commits
mailing list