@@ -823,8 +823,11 @@ static bool processUDivOrURem(BinaryOperator *Instr, LazyValueInfo *LVI) {
823
823
if (Instr->getType ()->isVectorTy ())
824
824
return false ;
825
825
826
- ConstantRange XCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ));
827
- ConstantRange YCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (1 ));
826
+ ConstantRange XCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ),
827
+ /* UndefAllowed*/ false );
828
+ // Allow undef for RHS, as we can assume it is division by zero UB.
829
+ ConstantRange YCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (1 ),
830
+ /* UndefAllowed*/ true );
828
831
if (expandUDivOrURem (Instr, XCR, YCR))
829
832
return true ;
830
833
@@ -951,8 +954,11 @@ static bool processSDivOrSRem(BinaryOperator *Instr, LazyValueInfo *LVI) {
951
954
if (Instr->getType ()->isVectorTy ())
952
955
return false ;
953
956
954
- ConstantRange LCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ));
955
- ConstantRange RCR = LVI->getConstantRangeAtUse (Instr->getOperandUse (1 ));
957
+ ConstantRange LCR =
958
+ LVI->getConstantRangeAtUse (Instr->getOperandUse (0 ), /* AllowUndef*/ false );
959
+ // Allow undef for RHS, as we can assume it is division by zero UB.
960
+ ConstantRange RCR =
961
+ LVI->getConstantRangeAtUse (Instr->getOperandUse (1 ), /* AlloweUndef*/ true );
956
962
if (Instr->getOpcode () == Instruction::SDiv)
957
963
if (processSDiv (Instr, LCR, RCR, LVI))
958
964
return true ;
0 commit comments