Skip to content

Commit 73f1062

Browse files
committed
Format the code
1 parent 4986843 commit 73f1062

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

llvm/lib/Transforms/InstCombine/InstCombineSelect.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3561,7 +3561,6 @@ static Instruction *foldBitCeil(SelectInst &SI, IRBuilderBase &Builder) {
35613561
// This function tries to fold the following operations:
35623562
// (x < y) ? -1 : zext(x != y)
35633563
// (x > y) ? 1 : sext(x != y)
3564-
// (x >= y) ? zext(x != y) : -1
35653564
// Into ucmp/scmp(x, y), where signedness is determined by the signedness
35663565
// of the comparison in the original sequence
35673566
Instruction *InstCombinerImpl::foldSelectToCmp(SelectInst &SI) {
@@ -3589,19 +3588,22 @@ Instruction *InstCombinerImpl::foldSelectToCmp(SelectInst &SI) {
35893588
Intrinsic::ID IID =
35903589
ICmpInst::isSigned(Pred) ? Intrinsic::scmp : Intrinsic::ucmp;
35913590

3592-
CallInst *Intrinsic = nullptr;
3591+
bool Replace = false;
35933592
// (x < y) ? -1 : zext(x != y)
35943593
if (ICmpInst::isLT(Pred) && match(TV, m_AllOnes()) &&
3595-
match(FV, m_ZExt(m_c_SpecificICmp(ICmpInst::ICMP_NE, m_Specific(LHS), m_Specific(RHS)))))
3596-
Intrinsic = Builder.CreateIntrinsic(SI.getType(), IID, {LHS, RHS});
3594+
match(FV, m_ZExt(m_c_SpecificICmp(ICmpInst::ICMP_NE, m_Specific(LHS),
3595+
m_Specific(RHS)))))
3596+
Replace = true;
35973597

35983598
// (x > y) ? 1 : sext(x != y)
35993599
if (ICmpInst::isGT(Pred) && match(TV, m_One()) &&
3600-
match(FV, m_SExt(m_c_SpecificICmp(ICmpInst::ICMP_NE, m_Specific(LHS), m_Specific(RHS)))))
3601-
Intrinsic = Builder.CreateIntrinsic(SI.getType(), IID, {LHS, RHS});
3600+
match(FV, m_SExt(m_c_SpecificICmp(ICmpInst::ICMP_NE, m_Specific(LHS),
3601+
m_Specific(RHS)))))
3602+
Replace = true;
36023603

3603-
if (Intrinsic)
3604-
return replaceInstUsesWith(SI, Intrinsic);
3604+
if (Replace)
3605+
return replaceInstUsesWith(
3606+
SI, Builder.CreateIntrinsic(SI.getType(), IID, {LHS, RHS}));
36053607
return nullptr;
36063608
}
36073609

0 commit comments

Comments
 (0)