[llvm] [InstCombine] Convert load from LUT into a select (PR #98339)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 17 09:01:57 PDT 2024
================
@@ -998,6 +998,105 @@ 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)
+ return nullptr;
+
+ auto *GV = dyn_cast<GlobalVariable>(GEP->getPointerOperand());
+ if (!GV || !GV->isConstant() || !GV->hasDefinitiveInitializer())
+ return nullptr;
+
+ Constant *Init = GV->getInitializer();
+ if (!isa<ConstantArray>(Init) && !isa<ConstantDataArray>(Init))
----------------
dtcxzyw wrote:
Done.
https://github.com/llvm/llvm-project/pull/98339
More information about the llvm-commits
mailing list