@@ -6035,28 +6035,29 @@ bool llvm::isSafeToSpeculativelyExecuteWithOpcode(
6035
6035
case Instruction::UDiv:
6036
6036
case Instruction::URem: {
6037
6037
// x / y is undefined if y == 0.
6038
- const DataLayout &DL = Inst->getModule ()->getDataLayout ();
6039
- return isKnownNonZero (Inst->getOperand (1 ), DL, /* Depth*/ 0 , AC, CtxI, DT);
6038
+ const APInt *V;
6039
+ if (match (Inst->getOperand (1 ), m_APInt (V)))
6040
+ return *V != 0 ;
6041
+ return false ;
6040
6042
}
6041
6043
case Instruction::SDiv:
6042
6044
case Instruction::SRem: {
6043
6045
// x / y is undefined if y == 0 or x == INT_MIN and y == -1
6044
- const DataLayout &DL = Inst-> getModule ()-> getDataLayout () ;
6045
- KnownBits KnownDenominator =
6046
- computeKnownBits (Inst-> getOperand ( 1 ), DL, /* Depth */ 0 , AC, CtxI, DT) ;
6046
+ const APInt *Numerator, *Denominator ;
6047
+ if (! match (Inst-> getOperand ( 1 ), m_APInt (Denominator)))
6048
+ return false ;
6047
6049
// We cannot hoist this division if the denominator is 0.
6048
- if (!KnownDenominator. isNonZero () )
6050
+ if (*Denominator == 0 )
6049
6051
return false ;
6050
-
6051
6052
// It's safe to hoist if the denominator is not 0 or -1.
6052
- if (!KnownDenominator. Zero . isZero ())
6053
+ if (!Denominator-> isAllOnes ())
6053
6054
return true ;
6054
-
6055
- // At this point denominator may be -1. It is safe to hoist as
6055
+ // At this point we know that the denominator is -1. It is safe to hoist as
6056
6056
// long we know that the numerator is not INT_MIN.
6057
- KnownBits KnownNumerator =
6058
- computeKnownBits (Inst->getOperand (0 ), DL, /* Depth*/ 0 , AC, CtxI, DT);
6059
- return !KnownNumerator.getSignedMinValue ().isMinSignedValue ();
6057
+ if (match (Inst->getOperand (0 ), m_APInt (Numerator)))
6058
+ return !Numerator->isMinSignedValue ();
6059
+ // The numerator *might* be MinSignedValue.
6060
+ return false ;
6060
6061
}
6061
6062
case Instruction::Load: {
6062
6063
const LoadInst *LI = dyn_cast<LoadInst>(Inst);
0 commit comments