[PATCH] D36215: [IRCE] Identify loops with latch comparison against current IV value

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 05:48:58 PDT 2017


mkazantsev added inline comments.


================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:848
+  const SCEV *IndVarStart = nullptr;
+  if (isa<PHINode>(LeftValue) &&
+      cast<PHINode>(LeftValue)->getParent() == Header)
----------------
anna wrote:
> I'm not sure if this is enough to identify that it's from the current IV. 
> 
> What if we had some "noop" operations on that phi node, and the result of that operation was used in the comparison? Wouldn't we incorrectly mark as this is from iv.next, whereas it's infact from the current IV.
> ```
> header:
> iv = phi [0, entry] [iv.next, latch]
> ...
> 
> latch:
> iv.trunc =  trunc iv to 16
> iv.next = iv + 1
> %cmp = slt iv.trunc, 100
> br %cmp, header, exit
> ```
> It could be bitcast or trunc or any other such operations. I think we need to "look through these operations" rather than directly comparing against a phi node.
> 
> Please add test cases as well.
> 
In current implementation, such case will be still recognized as comparison against `iv.next`. That's an interesting point, I need to think on it. Thanks for noticing that!


https://reviews.llvm.org/D36215





More information about the llvm-commits mailing list