[InstCombine] reduce code for swapped predicate; NFC

This commit is contained in:
Sanjay Patel 2021-09-28 09:59:57 -04:00
parent 1a1aed8da8
commit 1f8bead678
1 changed files with 4 additions and 5 deletions

View File

@ -5908,13 +5908,12 @@ Instruction *InstCombinerImpl::visitICmpInst(ICmpInst &I) {
if (Instruction *Res = foldICmpInstWithConstantNotInt(I))
return Res;
// If we can optimize a 'icmp GEP, P' or 'icmp P, GEP', do so now.
if (GEPOperator *GEP = dyn_cast<GEPOperator>(Op0))
// Try to optimize 'icmp GEP, P' or 'icmp P, GEP'.
if (auto *GEP = dyn_cast<GEPOperator>(Op0))
if (Instruction *NI = foldGEPICmp(GEP, Op1, I.getPredicate(), I))
return NI;
if (GEPOperator *GEP = dyn_cast<GEPOperator>(Op1))
if (Instruction *NI = foldGEPICmp(GEP, Op0,
ICmpInst::getSwappedPredicate(I.getPredicate()), I))
if (auto *GEP = dyn_cast<GEPOperator>(Op1))
if (Instruction *NI = foldGEPICmp(GEP, Op0, I.getSwappedPredicate(), I))
return NI;
// Try to optimize equality comparisons against alloca-based pointers.