[Regression] Missed Optimization at O3
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer: https://godbolt.org/z/aEas4aYqP
Description: LLVM (trunk -O3) cannot optimize the following C function annotated with value range information, while LLVM 20.1.0 and 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 trunk's O3 output:
```assembly
src:
mov ecx, esi
mov eax, edi
shr eax, cl
xor eax, esi
ret
```
Clang 20.1.0 O3 output:
```assembly
src:
mov eax, esi
ret
```
GCC's O3 output:
```assembly
src:
mov eax, esi
ret
```
Contributor guide
Assessment
This issue has not been assessed yet.