[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
Thu Aug 15 18:44:42 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:

Correct myself. Speculating a cload/cstore is not cheaper than speculating an add. But the load latency is typically 4, if we can load earlier, the consumer of the load will not have to wait for 4 cycles and hide the pipeline.

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


More information about the llvm-commits mailing list