Issue 53006
Summary Missed optimizations in conditionally selected constants
Labels
Assignees
Reporter uncleasm
    Compared to gcc, clang produces slightly more verbose code for a sequence

```
int test1(int a) { return a ? -1 : 1; }
        xor     eax, eax
        test    edi, edi
        sete    al
        add     eax, eax
        add     eax, -1
        ret
```

AFAIK, the optimal sequence is

```
neg edi
sbb eax, eax
or eax, 1
```

which could be encoded from
```
int test0(int a) { return a ? -1 : 0; }
        neg     edi
        sbb     eax, eax
        ret

int test1b(int a) { return test0(a) | 1; }
```

As a side note, gcc can produce the expected output from `test1b` but not from `test1`.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to