[llvm] [InstCombine] Convert load from LUT into a select (PR #98339)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 10 11:51:53 PDT 2024
================
@@ -998,6 +998,93 @@ static bool canSimplifyNullLoadOrGEP(LoadInst &LI, Value *Op) {
return false;
}
+static Value *foldLoadFromIndexedGlobal(LoadInst &LI, IRBuilderBase &Builder) {
+ if (LI.isVolatile())
+ return nullptr;
+
+ auto *GEP = dyn_cast<GetElementPtrInst>(LI.getPointerOperand());
+ if (!GEP || LI.getType() != GEP->getResultElementType())
+ return nullptr;
+
+ auto *GV = dyn_cast<GlobalVariable>(GEP->getPointerOperand());
+ if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer() ||
+ GV->getValueType() != GEP->getSourceElementType())
----------------
nikic wrote:
As usual, type based reasoning is not allowed. Convert to offsets instead.
https://github.com/llvm/llvm-project/pull/98339
More information about the llvm-commits
mailing list