Index: llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp =================================================================== --- llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp +++ llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp @@ -834,7 +834,8 @@ // ugt 0 is canonicalized to ne 0 and requires special handling // (a != 0) ? a + -1 : 0 -> usub.sat(a, 1) if (Pred == ICmpInst::ICMP_NE) { - if (match(B, m_Zero()) && match(TrueVal, m_Add(m_Specific(A), m_AllOnes()))) + if (!isa(A) && match(B, m_Zero()) && + match(TrueVal, m_Add(m_Specific(A), m_AllOnes()))) return Builder.CreateBinaryIntrinsic(Intrinsic::usub_sat, A, ConstantInt::get(A->getType(), 1)); return nullptr;