[PATCH] D17353: Set minimum cost of speculating an instruction.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 17 21:43:22 PST 2016


danielcdh added inline comments.

================
Comment at: lib/Transforms/Utils/SimplifyCFG.cpp:255
@@ +254,3 @@
+  if (Cost < TargetTransformInfo::TCC_Basic)
+    Cost = TargetTransformInfo::TCC_Basic;
+  return Cost;
----------------
davidxl wrote:
> My real question is why TTI.getUserCost(I) returns the wrong cost here :)
For this specific case, it's that GEP operator is mostly considered free (as soon as the addressing mode is legal). The reasoning is that if you dereference the output of GEP operator, the memory instruction can have the addressing encoded. But here GEP operator is not immediately used by a memory op. Instead, it's used later in other basic block, and the GEP operation actually translated to a real LEA instruction, thus it is not free.

I don't think it's quite right to set most GEP operator as 0-cost. But just by looking at the GEP operator itself, it's hard to tell whether it will be encoded into the memory op, or need to have separate instruction for it. In this case, it would be better to be conservative.

So what should I do? Change GEP operator's cost to TCC_Basic for all cases?


http://reviews.llvm.org/D17353





More information about the llvm-commits mailing list