forked from OSchip/llvm-project
[InstCombine] Refactor foldICmpMulConstant
This is a follow-up to 2ebfda2417
(replace "if" with "else if" since the cases nuw/nsw
were meant to be handled separately).
Test plan:
1/ ninja check-llvm check-clang check-lld
2/ Bootstrapped LLVM/Clang pass tests
This commit is contained in:
parent
a0d6105162
commit
d982f1e0c6
|
@ -2053,9 +2053,7 @@ Instruction *InstCombinerImpl::foldICmpMulConstant(ICmpInst &Cmp,
|
||||||
NewC = ConstantInt::get(
|
NewC = ConstantInt::get(
|
||||||
Mul->getType(),
|
Mul->getType(),
|
||||||
APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::DOWN));
|
APIntOps::RoundingSDiv(C, *MulC, APInt::Rounding::DOWN));
|
||||||
}
|
} else if (Mul->hasNoUnsignedWrap()) {
|
||||||
|
|
||||||
if (Mul->hasNoUnsignedWrap()) {
|
|
||||||
if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)
|
if (Pred == ICmpInst::ICMP_ULT || Pred == ICmpInst::ICMP_UGE)
|
||||||
NewC = ConstantInt::get(
|
NewC = ConstantInt::get(
|
||||||
Mul->getType(),
|
Mul->getType(),
|
||||||
|
|
|
@ -860,7 +860,9 @@ define i1 @splat_mul_known_lz(i32 %x) {
|
||||||
|
|
||||||
define i1 @splat_mul_unknown_lz(i32 %x) {
|
define i1 @splat_mul_unknown_lz(i32 %x) {
|
||||||
; CHECK-LABEL: @splat_mul_unknown_lz(
|
; CHECK-LABEL: @splat_mul_unknown_lz(
|
||||||
; CHECK-NEXT: [[R:%.*]] = icmp sgt i32 [[X:%.*]], -1
|
; CHECK-NEXT: [[Z:%.*]] = zext i32 [[X:%.*]] to i128
|
||||||
|
; CHECK-NEXT: [[M:%.*]] = mul nuw nsw i128 [[Z]], 18446744078004518913
|
||||||
|
; CHECK-NEXT: [[R:%.*]] = icmp ult i128 [[M]], 39614081257132168796771975168
|
||||||
; CHECK-NEXT: ret i1 [[R]]
|
; CHECK-NEXT: ret i1 [[R]]
|
||||||
;
|
;
|
||||||
%z = zext i32 %x to i128
|
%z = zext i32 %x to i128
|
||||||
|
|
Loading…
Reference in New Issue