[llvm] [X86, SimplifyCFG] Support hoisting load/store with conditional faulting (Part I) (PR #96878)

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 03:43:55 PDT 2024


================
@@ -3080,22 +3108,31 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
 
     // Only speculatively execute a single instruction (not counting the
     // terminator) for now.
-    ++SpeculatedInstructions;
+    bool IsSafeCheapLoadStore =
+        HositLoadsStores && isSafeCheapLoadStore(&I, TTI);
+    // Not count load/store into cost if target supports conditional faulting
+    // b/c it's cheap to speculate it.
----------------
KanRobert wrote:

Speculating a cload/cstore should be cheaper than an add b/c it behaves as a nop when the condition is not satisfied. We can add a flag to control the threshold of  speculated cload/cstore (let's use 6 as default FTTB).



https://github.com/llvm/llvm-project/pull/96878


More information about the llvm-commits mailing list