[all-commits] [llvm/llvm-project] 87779f: [RISCV][ISel] Remove redundant min/max in saturati...
Chia via All-commits
all-commits at lists.llvm.org
Fri Dec 29 00:16:00 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 87779fd823bb0d619c26449db91c7504ce7513c5
https://github.com/llvm/llvm-project/commit/87779fd823bb0d619c26449db91c7504ce7513c5
Author: Chia <sun1011jacobi at gmail.com>
Date: 2023-12-29 (Fri, 29 Dec 2023)
Changed paths:
M llvm/lib/Target/RISCV/RISCVInstrInfoVVLPatterns.td
M llvm/test/CodeGen/RISCV/rvv/fpclamptosat_vec.ll
A llvm/test/CodeGen/RISCV/rvv/trunc-sat-clip.ll
Log Message:
-----------
[RISCV][ISel] Remove redundant min/max in saturating truncation (#75145)
This patch closed #73424, which is also a missed-optimization case
similar to #68466 on X86.
## Source Code
```
define void @trunc_sat_i8i16(ptr %x, ptr %y) {
%1 = load <8 x i16>, ptr %x, align 16
%2 = tail call <8 x i16> @llvm.smax.v8i16(<8 x i16> %1, <8 x i16> <i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128, i16 -128>)
%3 = tail call <8 x i16> @llvm.smin.v8i16(<8 x i16> %2, <8 x i16> <i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127, i16 127>)
%4 = trunc <8 x i16> %3 to <8 x i8>
store <8 x i8> %4, ptr %y, align 8
ret void
}
```
## Before this patch:
```
trunc_sat_i8i16: # @trunc_maxmin_id_i8i16
vsetivli zero, 8, e16, m1, ta, ma
vle16.v v8, (a0)
li a0, -128
vmax.vx v8, v8, a0
li a0, 127
vmin.vx v8, v8, a0
vsetvli zero, zero, e8, mf2, ta, ma
vnsrl.wi v8, v8, 0
vse8.v v8, (a1)
ret
```
## After this patch:
```
trunc_sat_i8i16: # @trunc_maxmin_id_i8i16
vsetivli zero, 8, e8, mf2, ta, ma
vle16.v v8, (a0)
csrwi vxrm, 0
vnclip.wi v8, v8, 0
vse8.v v8, (a1)
ret
```
More information about the All-commits
mailing list