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

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 06:39:21 PDT 2024


phoebewang wrote:

> For cases like this why aren't we folding to:
> 
> ```
> void src(int a, int *c, int *d) {
>   if (a)
>    *c = a;
>   else
>    *d = a;
> }
> 
> void tgt(int a, int *c, int *d) {
>   int *p = a ? c : d;
>   *p = a;
> }
> ```
> 
> or the even more general:
> 
> ```
> void src(int s, int a, int b, int *c, int *d) {
>   if (s)
>    *c = a;
>   else
>    *d = b;
> }
> 
> void tgt(int s, int a, int b, int *c, int *d) {
>   int *p = s ? c : d;
>   int v = s ? a : b;
>   *p = v;
> }
> ```

That's a good question. It doesn't rely on hardware feature, so can be a general branch to select transformation. I'm also wondering why didn't we do it before, especially the first one. Is there any concern on possible sideeffect of memory operand?

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


More information about the llvm-commits mailing list