[PATCH] D54742: [CodeMetrics] Don't let extends of i1 be free.

Jonas Paulsson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 20 00:25:03 PST 2018


jonpa created this revision.
jonpa added reviewers: uweigand, eastig, chandlerc, efriedma, fhahn, craig.topper.

It seems that it is wrong and at the moment incomprehensible why there is code in getUserCost() that claims that extending an i1 is free "on most sane targets". At least not on SystemZ or X86 is this the case...

This patch removes this without any tests failing. What remains is to make sure that this does not introduce any performance regressions. It seems that on SystemZ and also preliminary on X86 this looks ok. Some additional benchmarking on more targets (and X86) would be welcome.

(This was originally https://reviews.llvm.org/D53373 -- a bit of discussion there)


https://reviews.llvm.org/D54742

Files:
  include/llvm/Analysis/TargetTransformInfoImpl.h


Index: include/llvm/Analysis/TargetTransformInfoImpl.h
===================================================================
--- include/llvm/Analysis/TargetTransformInfoImpl.h
+++ include/llvm/Analysis/TargetTransformInfoImpl.h
@@ -807,15 +807,9 @@
       return static_cast<T *>(this)->getCallCost(F, Arguments);
     }
 
-    if (const CastInst *CI = dyn_cast<CastInst>(U)) {
-      // Result of a cmp instruction is often extended (to be used by other
-      // cmp instructions, logical or return instructions). These are usually
-      // nop on most sane targets.
-      if (isa<CmpInst>(CI->getOperand(0)))
-        return TTI::TCC_Free;
+    if (const CastInst *CI = dyn_cast<CastInst>(U))
       if (isa<SExtInst>(CI) || isa<ZExtInst>(CI) || isa<FPExtInst>(CI))
         return static_cast<T *>(this)->getExtCost(CI, Operands.back());
-    }
 
     return static_cast<T *>(this)->getOperationCost(
         Operator::getOpcode(U), U->getType(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54742.174729.patch
Type: text/x-patch
Size: 953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181120/50fc8f13/attachment.bin>


More information about the llvm-commits mailing list