fix logical-select to invoke filecheck right, and fix hte instcombine
authorChris Lattner <sabre@nondot.org>
Fri, 5 Feb 2010 19:53:02 +0000 (19:53 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 5 Feb 2010 19:53:02 +0000 (19:53 +0000)
xform it is checking to actually pass.  There is no need to match
m_SelectCst<0, -1> since instcombine canonicalizes that into not(sext).

Add matches for sext(not(x)) in addition to not(sext(x)).

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

lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
test/Transforms/InstCombine/logical-select.ll

index f79e4fa371cb1f1ca86972da813b99bed84b2246..f0ddfe3fe1af991eb3648826e4dd606909e9c0ec 100644 (file)
@@ -1148,8 +1148,13 @@ static Instruction *MatchSelectFromAndOr(Value *A, Value *B,
   // ((cond?-1:0)&C) | (B&(cond?0:-1)) -> cond ? C : B.
   if (match(D, m_Not(m_SExt(m_Specific(Cond)))))
     return SelectInst::Create(Cond, C, B);
+  if (match(D, m_SExt(m_Not(m_Specific(Cond)))))
+    return SelectInst::Create(Cond, C, B);
+  
   // ((cond?-1:0)&C) | ((cond?0:-1)&D) -> cond ? C : D.
-  if (match(B, m_SelectCst<0, -1>(m_Specific(Cond))))
+  if (match(B, m_Not(m_SExt(m_Specific(Cond)))))
+    return SelectInst::Create(Cond, C, D);
+  if (match(B, m_SExt(m_Not(m_Specific(Cond)))))
     return SelectInst::Create(Cond, C, D);
   return 0;
 }
index 4e48b2dd7c7427063c6e739d95cab456a2d5da56..bb59817a4f6985e62e26e35ea36daeba3f03ea80 100644 (file)
@@ -1,4 +1,5 @@
-; RUN: opt < %s -instcombine -S > FileCheck %s
+; RUN: opt < %s -instcombine -S | FileCheck %s
+
 
 define i32 @foo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
   %e = icmp slt i32 %a, %b
@@ -24,6 +25,7 @@ define i32 @bar(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 ; CHECK: %j = select i1 %e, i32 %c, i32 %d
 ; CHECK: ret i32 %j
 }
+
 define i32 @goo(i32 %a, i32 %b, i32 %c, i32 %d) nounwind {
 entry:
   %0 = icmp slt i32 %a, %b