Index: llvm/lib/Analysis/InstructionSimplify.cpp =================================================================== --- llvm/lib/Analysis/InstructionSimplify.cpp +++ llvm/lib/Analysis/InstructionSimplify.cpp @@ -6586,6 +6586,11 @@ if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer()) return nullptr; + // If GlobalVariable's initializer is uniform, then return the constant + // regardless its offset. + if (Constant *C = + ConstantFoldLoadFromUniformValue(GV->getInitializer(), LI->getType())) + return C; // Try to convert operand into a constant by stripping offsets while looking // through invariant.group intrinsics. APInt Offset(Q.DL.getIndexTypeSizeInBits(PtrOp->getType()), 0);