@@ -1553,26 +1553,17 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2,
1553
1553
return ICmpInst::BAD_ICMP_PREDICATE;
1554
1554
}
1555
1555
}
1556
- } else {
1557
- ConstantExpr *CE2 = cast<ConstantExpr>(V2);
1558
- Constant *CE2Op0 = CE2->getOperand (0 );
1559
-
1560
- // There are MANY other foldings that we could perform here. They will
1561
- // probably be added on demand, as they seem needed.
1562
- switch (CE2->getOpcode ()) {
1563
- default : break ;
1564
- case Instruction::GetElementPtr:
1565
- // By far the most common case to handle is when the base pointers are
1566
- // obviously to the same global.
1567
- if (isa<GlobalValue>(CE1Op0) && isa<GlobalValue>(CE2Op0)) {
1568
- // Don't know relative ordering, but check for inequality.
1569
- if (CE1Op0 != CE2Op0) {
1570
- GEPOperator *CE2GEP = cast<GEPOperator>(CE2);
1571
- if (CE1GEP->hasAllZeroIndices () && CE2GEP->hasAllZeroIndices ())
1572
- return areGlobalsPotentiallyEqual (cast<GlobalValue>(CE1Op0),
1573
- cast<GlobalValue>(CE2Op0));
1574
- return ICmpInst::BAD_ICMP_PREDICATE;
1575
- }
1556
+ } else if (const auto *CE2GEP = dyn_cast<GEPOperator>(V2)) {
1557
+ // By far the most common case to handle is when the base pointers are
1558
+ // obviously to the same global.
1559
+ const Constant *CE2Op0 = cast<Constant>(CE2GEP->getPointerOperand ());
1560
+ if (isa<GlobalValue>(CE1Op0) && isa<GlobalValue>(CE2Op0)) {
1561
+ // Don't know relative ordering, but check for inequality.
1562
+ if (CE1Op0 != CE2Op0) {
1563
+ if (CE1GEP->hasAllZeroIndices () && CE2GEP->hasAllZeroIndices ())
1564
+ return areGlobalsPotentiallyEqual (cast<GlobalValue>(CE1Op0),
1565
+ cast<GlobalValue>(CE2Op0));
1566
+ return ICmpInst::BAD_ICMP_PREDICATE;
1576
1567
}
1577
1568
}
1578
1569
}
0 commit comments