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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 29 08:34:24 PDT 2024


nikic wrote:

> > I think that this isn't something SimplifyCFG should be handling.
> 
> This is completely opposite to what I thought. Can you tell me the reasoning behind your idea?

Probably worth considering this comment above the transform: https://github.com/llvm/llvm-project/blob/95ce78b742b2965f3a4a42115a96a330d779a98d/llvm/lib/Transforms/Utils/SimplifyCFG.cpp#L3153-L3162

I believe the machine passes it refers to are EarlyIfConversion and IfConversion. I do think it would be worthwhile to consider whether this transform isn't better handled there, as these passes can actually properly cost-model such transforms, unlike SimplifyCFG.

I'm not really familiar with these passes, but from a quick look at EarlyIfConversion, it seems to support two strategies, one which only does pure speculation (so no store speculation) and the other that does predication. For X86, what we want is a bit in the middle, in the sense that we only predicate load/store instructions and speculate the rest.

It's probably not so hard to extend that code with an additional policy for this case (or maybe extend the speculation policy to allow conditional load/store predication), and may give you better mileage than trying to do it in SimplifyCFG.

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


More information about the llvm-commits mailing list