diff --git a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp --- a/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -2612,42 +2612,6 @@ CmpInst::Predicate Pred; - if (SelType->isIntOrIntVectorTy(1) && - TrueVal->getType() == CondVal->getType()) { - if (match(TrueVal, m_One())) { - // Change: A = select B, true, C --> A = or B, C - return BinaryOperator::CreateOr(CondVal, FalseVal); - } - if (match(TrueVal, m_Zero())) { - // Change: A = select B, false, C --> A = and !B, C - Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName()); - return BinaryOperator::CreateAnd(NotCond, FalseVal); - } - if (match(FalseVal, m_Zero())) { - // Change: A = select B, C, false --> A = and B, C - return BinaryOperator::CreateAnd(CondVal, TrueVal); - } - if (match(FalseVal, m_One())) { - // Change: A = select B, C, true --> A = or !B, C - Value *NotCond = Builder.CreateNot(CondVal, "not." + CondVal->getName()); - return BinaryOperator::CreateOr(NotCond, TrueVal); - } - - // select a, a, b -> a | b - // select a, b, a -> a & b - if (CondVal == TrueVal) - return BinaryOperator::CreateOr(CondVal, FalseVal); - if (CondVal == FalseVal) - return BinaryOperator::CreateAnd(CondVal, TrueVal); - - // select a, ~a, b -> (~a) & b - // select a, b, ~a -> (~a) | b - if (match(TrueVal, m_Not(m_Specific(CondVal)))) - return BinaryOperator::CreateAnd(TrueVal, FalseVal); - if (match(FalseVal, m_Not(m_Specific(CondVal)))) - return BinaryOperator::CreateOr(TrueVal, FalseVal); - } - // Selecting between two integer or vector splat integer constants? // // Note that we don't handle a scalar select of vectors: @@ -2655,7 +2619,11 @@ // because that may need 3 instructions to splat the condition value: // extend, insertelement, shufflevector. if (SelType->isIntOrIntVectorTy() && - CondVal->getType()->isVectorTy() == SelType->isVectorTy()) { + CondVal->getType()->isVectorTy() == SelType->isVectorTy() && + TrueVal->getType()->isIntegerTy() && + TrueVal->getType()->getIntegerBitWidth() != 1 && + FalseVal->getType()->isIntegerTy() && + FalseVal->getType()->getIntegerBitWidth() != 1) { // select C, 1, 0 -> zext C to int if (match(TrueVal, m_One()) && match(FalseVal, m_Zero())) return new ZExtInst(CondVal, SelType);