fix PR6193, only considering sign extensions *from i1* for this
authorChris Lattner <sabre@nondot.org>
Tue, 9 Feb 2010 01:12:41 +0000 (01:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 9 Feb 2010 01:12:41 +0000 (01:12 +0000)
xform.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95642 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/crash.ll

index f0ddfe3fe1af991eb3648826e4dd606909e9c0ec..9de73bada7ecd7cce37da15c11e186e455553d46 100644 (file)
@@ -1142,19 +1142,24 @@ static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
                                          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;
 }
index a4e6a62d9e6e0dca7511b89f4e87607b75a4a19d..2faa5392d4ba6a2896d34a9a97e73c494615b129 100644 (file)
@@ -226,3 +226,14 @@ define void @test10a() {
   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
+}