[llvm-commits] [llvm] r95642 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/crash.ll

Chris Lattner sabre at nondot.org
Mon Feb 8 17:12:41 PST 2010


Author: lattner
Date: Mon Feb  8 19:12:41 2010
New Revision: 95642

URL: http://llvm.org/viewvc/llvm-project?rev=95642&view=rev
Log:
fix PR6193, only considering sign extensions *from i1* for this
xform.

Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    llvm/trunk/test/Transforms/InstCombine/crash.ll

Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp?rev=95642&r1=95641&r2=95642&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Mon Feb  8 19:12:41 2010
@@ -1142,19 +1142,24 @@
                                          Value *C, Value *D) {
   // If A is not a select of -1/0, this cannot match.
   Value *Cond = 0;
-  if (!match(A, m_SExt(m_Value(Cond))))
+  if (!match(A, m_SExt(m_Value(Cond))) ||
+      !Cond->getType()->isInteger(1))
     return 0;
 
   // ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
-  if (match(D, m_Not(m_SExt(m_Specific(Cond)))))
+  if (match(D, m_Not(m_SExt(m_Specific(Cond)))) &&
+      Cond->getType()->isInteger(1))
     return SelectInst::Create(Cond, C, B);
-  if (match(D, m_SExt(m_Not(m_Specific(Cond)))))
+  if (match(D, m_SExt(m_Not(m_Specific(Cond)))) &&
+      Cond->getType()->isInteger(1))
     return SelectInst::Create(Cond, C, B);
   
   // ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
-  if (match(B, m_Not(m_SExt(m_Specific(Cond)))))
+  if (match(B, m_Not(m_SExt(m_Specific(Cond)))) &&
+      Cond->getType()->isInteger(1))
     return SelectInst::Create(Cond, C, D);
-  if (match(B, m_SExt(m_Not(m_Specific(Cond)))))
+  if (match(B, m_SExt(m_Not(m_Specific(Cond)))) &&
+      Cond->getType()->isInteger(1))
     return SelectInst::Create(Cond, C, D);
   return 0;
 }

Modified: llvm/trunk/test/Transforms/InstCombine/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/crash.ll?rev=95642&r1=95641&r2=95642&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/crash.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/crash.ll Mon Feb  8 19:12:41 2010
@@ -226,3 +226,14 @@
   ret void
 }
 
+
+; PR6193
+define i32 @test11(i32 %aMaskWidth, i8 %aStride) nounwind {
+entry:
+  %conv41 = sext i8 %aStride to i32
+  %neg = xor i32 %conv41, -1
+  %and42 = and i32 %aMaskWidth, %neg
+  %and47 = and i32 130, %conv41
+  %or = or i32 %and42, %and47
+  ret i32 %or
+}





More information about the llvm-commits mailing list