[PATCH] D18867: [IndVarSimplify] Eliminate zext of a signed IV when the IV is known to be non-negative
Mitch Bodart via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 09:00:24 PDT 2016
mbodart added inline comments.
================
Comment at: lib/Transforms/Scalar/IndVarSimplify.cpp:1308
@@ -1307,1 +1307,3 @@
+ if ((isa<SExtInst>(DU.NarrowUse) && (IsSigned || DU.NeverNegative)) ||
+ (isa<ZExtInst>(DU.NarrowUse) && (!IsSigned || DU.NeverNegative))) {
Value *NewDef = DU.WideDef;
----------------
lihuang wrote:
> You are right, the DU.WideDef's upper bits will be zeros whether it was from a Zext or Sext. Here we need to verify that DU.NarrowUse is a Zext or Sext. I changed the checks here to include the 4 possible cases:
> 1. DU.NarrowUse is a Sext, WideIV is signed,
> 2. DU.NarrowUse is a Sext, WideIV is unsigned, but DU.NeverNegative is true
> 3. DU.NarrowUse is a Zext, WideIV is unsigned,
> 4. DU.NarrowUse is a Zext, WideIV is signed, but DU.NeverNegative is true
>
> added one more test for case 2.
This looks great.
I'll defer to the other reviewers on the isKnownPredicate issue.
http://reviews.llvm.org/D18867
More information about the llvm-commits
mailing list