| Issue |
204047
|
| Summary |
Possible Missed Optimization in O3
|
| Labels |
|
| Assignees |
|
| Reporter |
Apochens
|
Reproducer: https://godbolt.org/z/4Mr84e1j8
Description: LLVM (trunk -O3) cannot optimize the following C function annotated with value range information, while GCC (trunk -O3) can.
```c
int src(int v1_u8, int v2_u8, int v3_i8) {
if (!((8 <= v1_u8) && (v1_u8 <= 66))) __builtin_unreachable();
if (!((0 <= v2_u8) && (v2_u8 <= 1))) __builtin_unreachable();
if (!((1 <= v3_i8) && (v3_i8 <= 2))) __builtin_unreachable();
int i0_u8 = v2_u8 >> v3_i8;
int i1_u8 = v1_u8 ^ i0_u8;
return i1_u8;
}
```
Clang's O3 output:
```assembly
src:
mov ecx, edx
mov eax, esi
shr eax, cl
xor eax, edi
ret
```
GCC's O3 output:
```assembly
src:
mov eax, edi
ret
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs