Skip to content

Commit c0c7c76

Browse files
committed
fixup! Use m_SpecificICmp
1 parent 0d562a0 commit c0c7c76

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

llvm/lib/CodeGen/ExpandMemCmp.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ Value *MemCmpExpansion::getMemCmpOneBlock() {
668668
// We can generate more optimal code with a smaller number of operations
669669
if (CI->hasOneUser()) {
670670
auto *UI = cast<Instruction>(*CI->user_begin());
671-
CmpPredicate Pred;
671+
CmpPredicate Pred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
672672
uint64_t Shift;
673673
bool NeedsZExt = false;
674674
// This is a special case because instead of checking if the result is less
@@ -680,19 +680,17 @@ Value *MemCmpExpansion::getMemCmpOneBlock() {
680680
Shift == (CI->getType()->getIntegerBitWidth() - 1)) {
681681
Pred = ICmpInst::ICMP_SLT;
682682
NeedsZExt = true;
683-
} else if (match(UI, m_ICmp(Pred, m_Specific(CI), m_Zero()))) {
684-
// Compare with 0. Pred is already set.
685-
} else if (match(UI, m_ICmp(Pred, m_Specific(CI), m_AllOnes())) &&
686-
Pred == ICmpInst::ICMP_SGT) {
683+
} else if (match(UI, m_SpecificICmp(ICmpInst::ICMP_SGT, m_Specific(CI),
684+
m_AllOnes()))) {
687685
// Adjust predicate as if it compared with 0.
688686
Pred = ICmpInst::ICMP_SGE;
689-
} else if (match(UI, m_ICmp(Pred, m_Specific(CI), m_One())) &&
690-
Pred == ICmpInst::ICMP_SLT) {
687+
} else if (match(UI, m_SpecificICmp(ICmpInst::ICMP_SLT, m_Specific(CI),
688+
m_One()))) {
691689
// Adjust predicate as if it compared with 0.
692690
Pred = ICmpInst::ICMP_SLE;
693691
} else {
694-
// No match, invalidate Pred.
695-
Pred = ICmpInst::Predicate::BAD_ICMP_PREDICATE;
692+
// In case of a successful match this call will set `Pred` variable
693+
match(UI, m_ICmp(Pred, m_Specific(CI), m_Zero()));
696694
}
697695
// Generate new code and remove the original memcmp call and the user
698696
if (ICmpInst::isSigned(Pred)) {

0 commit comments

Comments
 (0)