[llvm] [LICM] Allow hoisting of InsertElementInst's past non-hoistable InsertElementInsts (PR #200532)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 1 02:36:19 PDT 2026
================
@@ -1058,6 +1074,87 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
return Changed;
}
+static bool hoistInsertPastInsert(
+ InsertElementInst *Ins, Loop *CurLoop, AAResults *AA, DominatorTree *DT,
+ const TargetLibraryInfo *TLI, BasicBlock *Preheader, BasicBlock *HoistDest,
+ ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC,
+ ScalarEvolution *SE, SinkAndHoistLICMFlags &Flags,
+ OptimizationRemarkEmitter *ORE,
+ SmallVectorImpl<Instruction *> &HoistedInstructions,
+ bool AllowSpeculation) {
+ SmallSet<uint64_t, 4> SeenIndexes;
+ InsertElementInst *Inner;
+ auto CanBypass = [&](auto &CanBypass, InsertElementInst *CurrIns,
+ bool IsHoistedInstruction) -> bool {
+ // Instruction being hoisted past must only have one use
+ if (!IsHoistedInstruction && !CurrIns->hasOneUse())
+ return false;
----------------
lukel97 wrote:
Instead of threading through a bool, can we just move this check down to before the recursive call on line 1123?
https://github.com/llvm/llvm-project/pull/200532
More information about the llvm-commits
mailing list