diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp | 7 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/logical-select.ll | 4 | 
2 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp index f79e4fa371c..f0ddfe3fe1a 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp @@ -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;  } diff --git a/llvm/test/Transforms/InstCombine/logical-select.ll b/llvm/test/Transforms/InstCombine/logical-select.ll index 4e48b2dd7c7..bb59817a4f6 100644 --- a/llvm/test/Transforms/InstCombine/logical-select.ll +++ b/llvm/test/Transforms/InstCombine/logical-select.ll @@ -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  | 

