[llvm-commits] [llvm] r95420 - in /llvm/trunk: lib/Transforms/InstCombine/InstCombineAndOrXor.cpp test/Transforms/InstCombine/logical-select.ll

Chris Lattner sabre at nondot.org
Fri Feb 5 11:53:03 PST 2010


Author: lattner
Date: Fri Feb  5 13:53:02 2010
New Revision: 95420

URL: http://llvm.org/viewvc/llvm-project?rev=95420&view=rev
Log:
fix logical-select to invoke filecheck right, and fix hte instcombine
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)).


Modified:
    llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
    llvm/trunk/test/Transforms/InstCombine/logical-select.ll

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

==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp Fri Feb  5 13:53:02 2010
@@ -1148,8 +1148,13 @@
   // ((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;
 }

Modified: llvm/trunk/test/Transforms/InstCombine/logical-select.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/logical-select.ll?rev=95420&r1=95419&r2=95420&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/logical-select.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/logical-select.ll Fri Feb  5 13:53:02 2010
@@ -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 @@
 ; 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





More information about the llvm-commits mailing list