// Do not transform "gepinst (gep constexpr (GV))" here, because forming
// "gepconstexpr (gep constexpr (GV))" will cause the two gep's to fold
// and will invalidate our notion of what Init is.
+ Constant *SubInit = 0;
if (!isa<ConstantExpr>(GEP->getOperand(0))) {
ConstantExpr *CE =
dyn_cast_or_null<ConstantExpr>(ConstantFoldInstruction(GEP));
if (Init && CE && CE->getOpcode() == Instruction::GetElementPtr)
- if (Constant *SubInit =
- ConstantFoldLoadThroughGEPConstantExpr(Init, CE))
- Changed |= CleanupConstantGlobalUsers(GEP, SubInit);
+ SubInit = ConstantFoldLoadThroughGEPConstantExpr(Init, CE);
}
+ Changed |= CleanupConstantGlobalUsers(GEP, SubInit);
if (GEP->use_empty()) {
GEP->eraseFromParent();