[PATCH] D18867: [IndVarSimplify] Eliminate zext of a signed IV when the IV is known to be non-negative
Li Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 21 16:05:36 PDT 2016
lihuang 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;
----------------
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.
http://reviews.llvm.org/D18867
More information about the llvm-commits
mailing list