[PATCH] D47928: [SimplifyIndVars] Eliminate redundant truncs

Max Kazantsev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 18 21:23:00 PDT 2018


mkazantsev added inline comments.


================
Comment at: test/Transforms/IndVarSimplify/eliminate-trunc.ll:242
+  br i1 %cmp, label %loop, label %exit
+exit:
+  ret void
----------------
reames wrote:
> I think this case is actually something missing in SCEV.  Let me walk through the logic by which we should be able to handle this.
> IV is known to be [0, UINT32_MAX-1] inclusive - since it must be less than some value %n and the trunc doesn't change behavior before that point.
> Thus, IV + 1 is known to not nuw wrap in the 32 bit domain.
> Thus, trunc(IV+1) doesn't loose any bits.
> Thus zext(trunc(IV+1)) == IV+1.
> 
> I think we're probably missing a range check somewhere inside the getZeroExt routine.  
> 
> Note this logic only works for strict less than.  Doing it for ule wouldn't work.  
We are not missing anything. `narrow.iv` gets removed by our transform. But LFTR manages to insert it back when replacing `ult` with `ne`. It is non-profitable behavior in LFTR.


https://reviews.llvm.org/D47928





More information about the llvm-commits mailing list