[PATCH] SCEVExpander incorrectly marks generated subtractions as nuw/nsw
Sanjoy Das
sanjoy at playingwithpointers.com
Thu Feb 26 11:53:46 PST 2015
REPOSITORY
rL LLVM
http://reviews.llvm.org/D7899
Files:
llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
Index: llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
+++ llvm/trunk/lib/Analysis/ScalarEvolutionExpander.cpp
@@ -1182,9 +1182,6 @@
}
}
- bool IncrementIsNUW = IsIncrementNUW(SE, Normalized);
- bool IncrementIsNSW = IsIncrementNSW(SE, Normalized);
-
// Save the original insertion point so we can restore it when we're done.
BuilderType::InsertPointGuard Guard(Builder);
@@ -1219,6 +1216,12 @@
// Expand the step somewhere that dominates the loop header.
Value *StepV = expandCodeFor(Step, IntTy, L->getHeader()->begin());
+ // The no-wrap behavior proved by IsIncrement(NUW|NSW) is only applicable if
+ // we actually do emit an addition. It does not apply if we emit a
+ // subtraction.
+ bool IncrementIsNUW = !useSubtract && IsIncrementNUW(SE, Normalized);
+ bool IncrementIsNSW = !useSubtract && IsIncrementNSW(SE, Normalized);
+
// Create the PHI.
BasicBlock *Header = L->getHeader();
Builder.SetInsertPoint(Header, Header->begin());
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7899.20787.patch
Type: text/x-patch
Size: 1112 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150226/3cd2e550/attachment.bin>
More information about the llvm-commits
mailing list