[llvm] [RISCV][ISel] Remove redundant min/max in saturating truncation (PR #75145)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 12 01:00:12 PST 2023
topperc wrote:
> > How can you use just vnsrl? vnsrl discards the upper bits without any max or min.
>
>
>
> Yes, you are right.
>
>
>
> But if the range created by a pair of max/min operation is precisely the range of the truncation destination,
>
> then the pair could be removed.
>
>
>
> In the above case, `[-128, 127]` is the value range of u8.
>
> Since we truncate the u16 vector into a u8 vector, removing the max/min won't change the final result, AFAIU.
Let's imagine the input is -32767(0x8001) in i16. The smax with -128 should give -128(0xff80). Then it will be truncated to 0x80 which is -128 in i8.
A vnsrl by itself will drop the upper bits and give 0x01. This is incorrect.
https://github.com/llvm/llvm-project/pull/75145
More information about the llvm-commits
mailing list