Skip to content

Commit 5163319

Browse files
committed
[InstCombine] Use ConstantInt::getBool instead of Constant::getIntegerValue. NFC.
See also https://reviews.llvm.org/D156238#inline-1546774
1 parent b423e1f commit 5163319

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5054,14 +5054,10 @@ InstCombinerImpl::foldICmpWithMinMaxImpl(Instruction &I,
50545054
case ICmpInst::ICMP_UGT:
50555055
case ICmpInst::ICMP_SGE:
50565056
case ICmpInst::ICMP_UGE: {
5057-
auto FoldIntoConstant = [&](bool Value) {
5058-
return replaceInstUsesWith(
5059-
I, Constant::getIntegerValue(
5060-
I.getType(), APInt(1U, static_cast<uint64_t>(Value))));
5061-
};
50625057
auto FoldIntoCmpYZ = [&]() -> Instruction * {
50635058
if (CmpYZ.has_value())
5064-
return FoldIntoConstant(*CmpYZ);
5059+
return replaceInstUsesWith(I,
5060+
ConstantInt::getBool(I.getType(), *CmpYZ));
50655061
return ICmpInst::Create(Instruction::ICmp, Pred, Y, Z);
50665062
};
50675063

@@ -5073,7 +5069,7 @@ InstCombinerImpl::foldICmpWithMinMaxImpl(Instruction &I,
50735069
// min(X, Y) <= Z X <= Z true
50745070
// max(X, Y) > Z X > Z true
50755071
// max(X, Y) >= Z X >= Z true
5076-
return FoldIntoConstant(true);
5072+
return replaceInstUsesWith(I, ConstantInt::getTrue(I.getType()));
50775073
} else {
50785074
// Expr Fact Result
50795075
// max(X, Y) < Z X < Z Y < Z
@@ -5096,7 +5092,7 @@ InstCombinerImpl::foldICmpWithMinMaxImpl(Instruction &I,
50965092
// max(X, Y) <= Z X > Z false
50975093
// min(X, Y) > Z X <= Z false
50985094
// min(X, Y) >= Z X < Z false
5099-
return FoldIntoConstant(false);
5095+
return replaceInstUsesWith(I, ConstantInt::getFalse(I.getType()));
51005096
}
51015097
}
51025098
break;

0 commit comments

Comments
 (0)