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

Shengchen Kan via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 4 01:56:23 PDT 2024


KanRobert wrote:

> I wonder whether it is feasible to allow masked.load/masked.store to be used with scalars. The need to cast between `<1 x %T>` and `%T` everywhere is quite awkward and doesn't represent the underlying instructions well.

In theory, we should let `hoistLoadStoreWithCondFaultingFromSuccessors, hoistCommonCodeFromSuccessors, SpeculativelyExecuteBB` appear in one pass, because the former can bring more optimization opportunities to the latter two. This is the reason why I want to do it in `SimplifyCFG`, not after `CodeGen`. `SimplifyCFGOption` provides an opportunity to run it in a late pipeline so that some mid-end optimizations don't have to handle it well. Maybe we can 

1. run these three transforms of `SimplifyCFG` before `CodeGenPrepare` if the target supports conditional faulting, to avoid the awkwardness?  
2. extend LLVM IR to support scalar versioned `masked.load/store`.
3. enhance the support for masked loads/stores for `1x %T` throughout the middle-end passes after `SimplifyCFG`

Or any better idea? @nikic @dtcxzyw 

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


More information about the llvm-commits mailing list