[llvm] [X86, SimplifyCFG] Support hoisting load/store with conditional faulting (Part II) (PR #108812)
Shengchen Kan via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 25 18:46:08 PDT 2024
================
@@ -1771,6 +1782,25 @@ bool SimplifyCFGOpt::hoistCommonCodeFromSuccessors(Instruction *TI,
if (Succ->hasAddressTaken() || !Succ->getSinglePredecessor())
return false;
+ auto *BI = dyn_cast<BranchInst>(TI);
+ if (BI && HoistLoadsStoresWithCondFaulting &&
+ Options.HoistLoadsStoresWithCondFaulting) {
+ SmallVector<Instruction *, 2> SpeculatedConditionalLoadsStores;
+ for (auto *Succ : successors(BB)) {
+ for (Instruction &I : drop_end(*Succ)) {
+ if (!isSafeCheapLoadStore(&I, TTI) ||
+ SpeculatedConditionalLoadsStores.size() ==
+ HoistLoadsStoresWithCondFaultingThreshold)
+ return false;
+ SpeculatedConditionalLoadsStores.push_back(&I);
+ }
+ }
+
+ if (!SpeculatedConditionalLoadsStores.empty())
----------------
KanRobert wrote:
Considering current implementation separates the common instr hoist from load/store hoist,
probably we should move the code to
```C
if (BI->getSuccessor(0)->getSinglePredecessor()) {
if (BI->getSuccessor(1)->getSinglePredecessor()) {
if (HoistCommon && hoistCommonCodeFromSuccessors(
BI->getParent(), !Options.HoistCommonInsts))
return requestResimplify();
if (HoistLoadsStoresWithCondFaulting &&
Options.HoistLoadsStoresWithCondFaulting && hoistConditionalLoadsStores(...))
return requestResimplify();
```
https://github.com/llvm/llvm-project/pull/108812
More information about the llvm-commits
mailing list