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

```c
int src(unsigned v1_u8, int v3_i8) {
 if (!((1 <= v1_u8) && (v1_u8 <= 2))) __builtin_unreachable();
  if (!((6 <= v3_i8) && (v3_i8 <= 7))) __builtin_unreachable();
  int i0_i8 = v3_i8 >> v1_u8;
  int i1_i8 = v3_i8 | i0_i8;
  return i1_i8;
}
```

Clang at O3:
```assembly
src:
        mov     ecx, edi
        mov     eax, esi
 shr     eax, cl
        or      eax, esi
        ret
```

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

Reply via email to