Issue 204049
Summary Possible Missed Optimization at O3
Labels new issue
Assignees
Reporter Apochens
    Reproducer: https://godbolt.org/z/aEas4aYqP
Description: LLVM (trunk -O3) cannot optimize the following C function annotated with value range information, while GCC (trunk -O3) can.

```c
int src(int v0_u8, int v1_u8) {
  if (!((0 <= v0_u8) && (v0_u8 <= 1))) __builtin_unreachable();
  if (!((1 <= v1_u8) && (v1_u8 <= 2))) __builtin_unreachable();
  int i0_u8 = v0_u8 >> v1_u8;
  int i1_u8 = v1_u8 ^ i0_u8;
  return i1_u8;
}
```

Clang's O3 output:
```assembly
src:
        mov     ecx, esi
        mov     eax, edi
        shr     eax, cl
        xor     eax, esi
 ret
```

GCC's O3 output:
```assembly
src:
        mov     eax, esi
 ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to