[x86] Eliminate `movzx` when upper part of register is irrelevant or overwritten
Open
backend:X86
good first issue
llvm:SelectionDAG
missed-optimization
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
```zig
export fn foo(x: u8) u32 {
return @ctz(x >> 1);
}
```
```asm
foo:
shr dil
movzx eax, dil
or eax, 256
tzcnt eax, eax
ret
```
Could be:
```asm
foo:
shr dil
or edi, 256
tzcnt eax, edi
ret
```
The compiler could also look for things like `or eax, -256` and eliminate `movzx eax, al` since the relevant bits are overwritten anyway.
Contributor guide
Assessment
This issue has not been assessed yet.