Issue 76524
Summary x86 missed optimization for trunc i32 to i16 or i8 when ConstantRange of source already fits in destination
Labels new issue
Assignees
Reporter MitalAshok
    An unnecessary zeroextend / signextend is emitted to zero bits that are already assumed to be zero.

For example:

```c++
void take_u16(std::uint16_t);
void u32_to_u16(std::uint32_t x) {
 __builtin_assume(std::in_range<std::uint16_t>(x));
 take_u16(x);
}
```

Emits an unnecessary `movzwl  %di, %edi` before the tail call. GCC optimizes this to just jump to `take_u16`.

https://godbolt.org/z/qE77z3a7d

This optimization can also be done on other targets
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to