Created
August 3, 2020 18:24
-
-
Save pnkfelix/6e8c3c4b990133864173e4ef0ad6bea8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
index c3e46c1fade..e11cdfa7d16 100644 | |
--- a/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
+++ b/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
@@ -2110,6 +2110,8 @@ void LSRInstance::OptimizeShadowIV() { | |
if (!AR) continue; | |
if (IsSigned && !AR->hasNoSignedWrap()) continue; | |
if (!IsSigned && !AR->hasNoUnsignedWrap()) continue; | |
+ // FIXME: the above logic may need revisiting; hasNoUnsignedWrap can be used | |
+ // in conjunction with signed inputs. | |
Type *SrcTy = PH->getType(); | |
int Mantissa = DestTy->getFPMantissaWidth(); | |
@@ -3249,6 +3251,19 @@ void LSRInstance::CollectFixupsAndInitialFormulae() { | |
User::op_iterator UseI = | |
find(UserInst->operands(), U.getOperandValToReplace()); | |
assert(UseI != UserInst->op_end() && "cannot find IV operand"); | |
+ | |
+ // pnk: This may be where I should add the check if the input uses nsw/nuw | |
+ if (auto *BinOp = dyn_cast<OverflowingBinaryOperator>(UserInst)) { | |
+ if (BinOp->hasNoUnsignedWrap() || BinOp->hasNoSignedWrap()) { | |
+ LLVM_DEBUG(dbgs() << "Use: " << **UseI << " has no-wrap flags; discard\n"); | |
+ continue; | |
+ } else { | |
+ LLVM_DEBUG(dbgs() << "Use: " << **UseI << " has no no-wrap flags\n"); | |
+ } | |
+ } else { | |
+ LLVM_DEBUG(dbgs() << "Use: " << **UseI << " is not an overflowing binop\n"); | |
+ } | |
+ | |
if (IVIncSet.count(UseI)) { | |
LLVM_DEBUG(dbgs() << "Use is in profitable chain: " << **UseI << '\n'); | |
continue; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment