[PATCH] Make ScalarEvolution less aggressive with respect to no-wrap flags.
Sanjoy Das
sanjoy at playingwithpointers.com
Wed Jan 21 11:09:19 PST 2015
Replies inline.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:3149-3160
@@ -3148,13 +3148,14 @@
/// getMinusSCEV - Return LHS-RHS. Minus is represented in SCEV as A+B*-1.
const SCEV *ScalarEvolution::getMinusSCEV(const SCEV *LHS, const SCEV *RHS,
SCEV::NoWrapFlags Flags) {
assert(!maskFlags(Flags, SCEV::FlagNUW) && "subtraction does not have NUW");
// Fast path: X - X --> 0.
if (LHS == RHS)
return getConstant(LHS->getType(), 0);
- // X - Y --> X + -Y
- return getAddExpr(LHS, getNegativeSCEV(RHS), Flags);
+ // X - Y --> X + -Y.
+ // X -(nsw || nuw) Y --> X + -Y.
+ return getAddExpr(LHS, getNegativeSCEV(RHS));
}
----------------
majnemer wrote:
> `Flags` doesn't seem very useful now, perhaps it should be removed?
Yup, I'll do that in a follow-up refactoring change.
================
Comment at: lib/Analysis/ScalarEvolution.cpp:3464-3469
@@ -3463,8 +3464,2 @@
}
- } else if (const SubOperator *OBO =
- dyn_cast<SubOperator>(BEValueV)) {
- if (OBO->hasNoUnsignedWrap())
- Flags = setFlags(Flags, SCEV::FlagNUW);
- if (OBO->hasNoSignedWrap())
- Flags = setFlags(Flags, SCEV::FlagNSW);
}
----------------
atrick wrote:
> Add a short comment that subtract does not preserve nsw/nuw Flags.
Will do.
http://reviews.llvm.org/D7081
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
More information about the llvm-commits
mailing list