summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2011-08-14 04:51:49 +0000
committerNick Lewycky <nicholas@mxc.ca>2011-08-14 04:51:49 +0000
commit746e317953f268a17a2b8f6b95658e0861e73254 (patch)
tree9e4b6a16e8e0561621e7540005f0c2f3cd876e42
parent0be3970804a4c4db7be3fe08cd30072c8cee125d (diff)
downloadbcm5719-llvm-746e317953f268a17a2b8f6b95658e0861e73254.tar.gz
bcm5719-llvm-746e317953f268a17a2b8f6b95658e0861e73254.zip
This transform is not safe. Thanks to Eli for pointing that out!
llvm-svn: 137575
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp9
-rw-r--r--llvm/test/Transforms/InstCombine/nsw.ll20
2 files changed, 11 insertions, 18 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 41666361141..41d542af685 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -294,14 +294,7 @@ bool InstCombiner::SimplifyAssociativeOrCommutative(BinaryOperator &I) {
I.setOperand(1, Folded);
// Conservatively clear the optional flags, since they may not be
// preserved by the reassociation.
- if (MaintainNoSignedWrap(I, C1, C2) && Op0->hasNoSignedWrap() &&
- Op1->hasNoSignedWrap()) {
- New->setHasNoSignedWrap(true);
- I.clearSubclassOptionalData();
- I.setHasNoSignedWrap(true);
- } else {
- I.clearSubclassOptionalData();
- }
+ I.clearSubclassOptionalData();
Changed = true;
continue;
diff --git a/llvm/test/Transforms/InstCombine/nsw.ll b/llvm/test/Transforms/InstCombine/nsw.ll
index 0e715075fc3..0140c2f8012 100644
--- a/llvm/test/Transforms/InstCombine/nsw.ll
+++ b/llvm/test/Transforms/InstCombine/nsw.ll
@@ -46,16 +46,6 @@ define i32 @preserve1(i32 %x) nounwind {
ret i32 %add3
}
-; CHECK: @preserve2
-; CHECK: add nsw i8 %A, %B
-; CHECK: add nsw i8
-define i8 @preserve2(i8 %A, i8 %B) nounwind {
- %x = add nsw i8 %A, 10
- %y = add nsw i8 %B, 10
- %add = add nsw i8 %x, %y
- ret i8 %add
-}
-
; CHECK: @nopreserve1
; CHECK: add i8 %x, -126
define i8 @nopreserve1(i8 %x) nounwind {
@@ -81,3 +71,13 @@ define i8 @nopreserve3(i8 %A, i8 %B) nounwind {
%add = add nsw i8 %x, %y
ret i8 %add
}
+
+; CHECK: @nopreserve4
+; CHECK: add i8 %A, %B
+; CHECK: add i8
+define i8 @nopreserve4(i8 %A, i8 %B) nounwind {
+ %x = add nsw i8 %A, 10
+ %y = add nsw i8 %B, 10
+ %add = add nsw i8 %x, %y
+ ret i8 %add
+}
OpenPOWER on IntegriCloud