[llvm] [X86, SimplifyCFG] Support hoisting load/store with conditional faulting (Part I) (PR #96878)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 5 09:35:56 PDT 2024
================
@@ -3214,6 +3238,112 @@ bool SimplifyCFGOpt::speculativelyExecuteBB(BranchInst *BI,
BB->splice(BI->getIterator(), ThenBB, ThenBB->begin(),
std::prev(ThenBB->end()));
+ // If the target supports conditional faulting,
+ // we are looking for code like the following:
+ // \code
+ // BB:
+ // ...
+ // %cond = icmp ult %x, %y
+ // br i1 %cond, label %TrueBB, label %FalseBB
+ // FalseBB:
+ // store i32 1, ptr %q, align 4
+ // ...
+ // TrueBB:
+ // %0 = load i32, ptr %b, align 4
+ // store i32 %0, ptr %p, align 4
+ // ...
+ // \endcode
+ //
+ // and transform it into:
+ //
+ // \code
+ // BB:
+ // ...
+ // %cond = icmp ult %x, %y
+ // %0 = cload i32, ptr %b, %cond
+ // cstore i32 %0, ptr %p, %cond
+ // cstore i32 1, ptr %q, ~%cond
+ // br i1 %cond, label %TrueBB, label %FalseBB
+ // FalseBB:
+ // ...
+ // TrueBB:
+ // ...
+ // \endcode
+ //
+ // where cload/cstore is represented by intrinsic like llvm.masked.load/store,
----------------
antoniofrighetto wrote:
```suggestion
// where cload/cstore are represented by llvm.masked.load/store intrinsics,
```
https://github.com/llvm/llvm-project/pull/96878
More information about the llvm-commits
mailing list