diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/lib/Analysis/ValueTracking.cpp @@ -2767,8 +2767,8 @@ I->getOperand(1)); case Instruction::Or: // X | Y != 0 if X != 0 or Y != 0. - return isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q) || - isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q); + return isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q) || + isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q); case Instruction::SExt: case Instruction::ZExt: // ext X != 0 if X != 0. @@ -2833,8 +2833,8 @@ // non-zero. auto *BO = cast(V); if (Q.IIQ.hasNoUnsignedWrap(BO)) - return isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q) || - isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q); + return isKnownNonZero(I->getOperand(1), DemandedElts, Depth, Q) || + isKnownNonZero(I->getOperand(0), DemandedElts, Depth, Q); if (isNonZeroAdd(DemandedElts, Depth, Q, BitWidth, I->getOperand(0), I->getOperand(1))) @@ -2935,10 +2935,8 @@ break; case Intrinsic::umax: case Intrinsic::uadd_sat: - if (isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q) || - isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q)) - return true; - break; + return isKnownNonZero(II->getArgOperand(1), DemandedElts, Depth, Q) || + isKnownNonZero(II->getArgOperand(0), DemandedElts, Depth, Q); case Intrinsic::smin: case Intrinsic::smax: { auto KnownOpImpliesNonZero = [&](const KnownBits &K) {