[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
Wed Sep 25 00:59:45 PDT 2024


phoebewang wrote:

E2E tests:
```
$ cat apx.c
void test1 (int a, int *c, int *d) {
  if (a)
   *c = a;
  else
   *d = a;
}
int test2 (int a, int *c, int *d) {
  if (a) {
   *c = a;
   return 2;
  } else {
   *d = a;
   return 3;
  }
}
$ clang -O2 -mapxf apx.c -S -o -
        .text
        .file   "apx.c"
        .globl  test1                           # -- Begin function test1
        .p2align        4, 0x90
        .type   test1, at function
test1:                                  # @test1
        .cfi_startproc
# %bb.0:                                # %entry
        xorl    %eax, %eax
        testl   %edi, %edi
        cfcmovel        %eax, (%rdx)
        cfcmovnel       %edi, (%rsi)
        retq
.Lfunc_end0:
        .size   test1, .Lfunc_end0-test1
        .cfi_endproc
                                        # -- End function
        .globl  test2                           # -- Begin function test2
        .p2align        4, 0x90
        .type   test2, at function
test2:                                  # @test2
        .cfi_startproc
# %bb.0:                                # %entry
        xorl    %ecx, %ecx
        testl   %edi, %edi
        setzue  %al
        cfcmovel        %ecx, (%rdx)
        cfcmovnel       %edi, (%rsi)
        orl     $2, %eax
        retq
.Lfunc_end1:
        .size   test2, .Lfunc_end1-test2
        .cfi_endproc
                                        # -- End function
```

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


More information about the llvm-commits mailing list