Issue 233455
Summary [X86] Unnecessary `mov al, 123; movzx eax, al` for `123 / int8`
Labels new issue
Assignees
Reporter dzaima
    This code:
```c
#include<stdint.h>
int8_t div_i8(int8_t x) {
  return 123 / x;
}
uint8_t div_u8(uint8_t x) {
 return 123 / x;
}
```
compiles to:
```asm
div_i8:
        mov     al, 123
        movzx   eax, al
        idiv    dil
        ret

div_u8:
 mov     al, 123
        movzx   eax, al
        div     dil
 ret
```
but those `mov`+`movzx` could be just `mov eax, 123`, at the same code size, but avoiding a false dependency and being one less instr & uop.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to