@@ -1252,25 +1252,6 @@ static ICmpInst::Predicate evaluateICmpRelation(Constant *V1, Constant *V2) {
1252
1252
return ICmpInst::BAD_ICMP_PREDICATE;
1253
1253
}
1254
1254
1255
- static Constant *constantFoldCompareGlobalToNull (CmpInst::Predicate Predicate,
1256
- Constant *C1, Constant *C2) {
1257
- const GlobalValue *GV = dyn_cast<GlobalValue>(C2);
1258
- if (!GV || !C1->isNullValue ())
1259
- return nullptr ;
1260
-
1261
- // Don't try to evaluate aliases. External weak GV can be null.
1262
- if (!isa<GlobalAlias>(GV) && !GV->hasExternalWeakLinkage () &&
1263
- !NullPointerIsDefined (nullptr /* F */ ,
1264
- GV->getType ()->getAddressSpace ())) {
1265
- if (Predicate == ICmpInst::ICMP_EQ)
1266
- return ConstantInt::getFalse (C1->getContext ());
1267
- else if (Predicate == ICmpInst::ICMP_NE)
1268
- return ConstantInt::getTrue (C1->getContext ());
1269
- }
1270
-
1271
- return nullptr ;
1272
- }
1273
-
1274
1255
Constant *llvm::ConstantFoldCompareInstruction (CmpInst::Predicate Predicate,
1275
1256
Constant *C1, Constant *C2) {
1276
1257
Type *ResultTy;
@@ -1309,14 +1290,6 @@ Constant *llvm::ConstantFoldCompareInstruction(CmpInst::Predicate Predicate,
1309
1290
return ConstantInt::get (ResultTy, CmpInst::isUnordered (Predicate));
1310
1291
}
1311
1292
1312
- // icmp eq/ne(null,GV) -> false/true
1313
- if (Constant *Folded = constantFoldCompareGlobalToNull (Predicate, C1, C2))
1314
- return Folded;
1315
-
1316
- // icmp eq/ne(GV,null) -> false/true
1317
- if (Constant *Folded = constantFoldCompareGlobalToNull (Predicate, C2, C1))
1318
- return Folded;
1319
-
1320
1293
if (C2->isNullValue ()) {
1321
1294
// The caller is expected to commute the operands if the constant expression
1322
1295
// is C2.
0 commit comments