[llvm-commits] [llvm] r152066 - in /llvm/trunk: lib/Analysis/ValueTracking.cpp test/Transforms/InstSimplify/phi.ll

Eli Friedman eli.friedman at gmail.com
Mon Mar 5 15:09:40 PST 2012


Author: efriedma
Date: Mon Mar  5 17:09:40 2012
New Revision: 152066

URL: http://llvm.org/viewvc/llvm-project?rev=152066&view=rev
Log:
Make sure we don't return bits outside the mask in ComputeMaskedBits.  PR12189.


Added:
    llvm/trunk/test/Transforms/InstSimplify/phi.ll
Modified:
    llvm/trunk/lib/Analysis/ValueTracking.cpp

Modified: llvm/trunk/lib/Analysis/ValueTracking.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ValueTracking.cpp?rev=152066&r1=152065&r2=152066&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ValueTracking.cpp (original)
+++ llvm/trunk/lib/Analysis/ValueTracking.cpp Mon Mar  5 17:09:40 2012
@@ -691,8 +691,8 @@
       if (P->hasConstantValue() == P)
         break;
 
-      KnownZero = APInt::getAllOnesValue(BitWidth);
-      KnownOne = APInt::getAllOnesValue(BitWidth);
+      KnownZero = Mask;
+      KnownOne = Mask;
       for (unsigned i = 0, e = P->getNumIncomingValues(); i != e; ++i) {
         // Skip direct self references.
         if (P->getIncomingValue(i) == P) continue;

Added: llvm/trunk/test/Transforms/InstSimplify/phi.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstSimplify/phi.ll?rev=152066&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstSimplify/phi.ll (added)
+++ llvm/trunk/test/Transforms/InstSimplify/phi.ll Mon Mar  5 17:09:40 2012
@@ -0,0 +1,22 @@
+; RUN: opt < %s -instsimplify -S | FileCheck %s
+
+; PR12189
+define i1 @test1(i32 %x) {
+; CHECK: @test1
+  br i1 true, label %a, label %b
+
+a:
+  %aa = or i32 %x, 10
+  br label %c
+
+b:
+  %bb = or i32 %x, 10
+  br label %c
+
+c:
+  %cc = phi i32 [ %bb, %b ], [%aa, %a ]
+  %d = urem i32 %cc, 2
+  %e = icmp eq i32 %d, 0
+  ret i1 %e
+; CHECK: ret i1 %e
+}





More information about the llvm-commits mailing list