[llvm-commits] [llvm] r137575 - in /llvm/trunk: lib/Transforms/InstCombine/InstructionCombining.cpp test/Transforms/InstCombine/nsw.ll

Nick Lewycky nicholas at mxc.ca
Sat Aug 13 21:51:49 PDT 2011


Author: nicholas
Date: Sat Aug 13 23:51:49 2011
New Revision: 137575

URL: http://llvm.org/viewvc/llvm-project?rev=137575&view=rev
Log:
This transform is not safe. Thanks to Eli for pointing that out!

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
    llvm/trunk/test/Transforms/InstCombine/nsw.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp?rev=137575&r1=137574&r2=137575&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstructionCombining.cpp Sat Aug 13 23:51:49 2011
@@ -294,14 +294,7 @@
         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;

Modified: llvm/trunk/test/Transforms/InstCombine/nsw.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/nsw.ll?rev=137575&r1=137574&r2=137575&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/nsw.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/nsw.ll Sat Aug 13 23:51:49 2011
@@ -46,16 +46,6 @@
   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 @@
   %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
+}





More information about the llvm-commits mailing list