[PATCH] [BUG] Fix regression after r214385
Zinovy Nis
zinovy.nis at gmail.com
Thu Aug 21 07:00:34 PDT 2014
Hi majnemer, bkramer,
r214385 fixed PR20189, but introduced a regression in cases where sub is used for immediates:
with r214385
```
sub nsw %x, 123 ====> add %x, -123
```
losing nsw/nuw attributes.
This patch fixes such a behavior for non-binary operations.
http://reviews.llvm.org/D5007
Files:
lib/Transforms/InstCombine/InstCombineAddSub.cpp
Index: lib/Transforms/InstCombine/InstCombineAddSub.cpp
===================================================================
--- lib/Transforms/InstCombine/InstCombineAddSub.cpp
+++ lib/Transforms/InstCombine/InstCombineAddSub.cpp
@@ -1539,6 +1539,10 @@
"Expected a subtraction operator!");
if (BO->hasNoSignedWrap() && I.hasNoSignedWrap())
Res->setHasNoSignedWrap(true);
+ } else {
+ // Preserve nsw/nuw for non-binary operations.
+ Res->setHasNoSignedWrap(I.hasNoSignedWrap());
+ Res->setHasNoUnsignedWrap(I.hasNoUnsignedWrap());
}
return Res;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D5007.12767.patch
Type: text/x-patch
Size: 605 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140821/53c77e2e/attachment.bin>
More information about the llvm-commits
mailing list