[InstCombine] check for one-use before turning simple logic op into a select
llvm-svn: 274891
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index f6ec03b..eadf0bf 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -2394,10 +2394,10 @@
return CastedOr;
// or(sext(A), B) / or(B, sext(A)) --> A ? -1 : B, where A is i1 or <N x i1>.
- if (match(Op0, m_SExt(m_Value(A))) &&
+ if (match(Op0, m_OneUse(m_SExt(m_Value(A)))) &&
A->getType()->getScalarType()->isIntegerTy(1))
return SelectInst::Create(A, ConstantInt::getSigned(I.getType(), -1), Op1);
- if (match(Op1, m_SExt(m_Value(A))) &&
+ if (match(Op1, m_OneUse(m_SExt(m_Value(A)))) &&
A->getType()->getScalarType()->isIntegerTy(1))
return SelectInst::Create(A, ConstantInt::getSigned(I.getType(), -1), Op0);