Skip to content

Commit 06c988c

Browse files
authored
[RISCV][VLOPT] Add support for vwsll.vx/vv. (#146998)
1 parent 5a9e6ba commit 06c988c

File tree

2 files changed

+53
-7
lines changed

2 files changed

+53
-7
lines changed

llvm/lib/Target/RISCV/RISCVVLOptimizer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,8 @@ getOperandLog2EEW(const MachineOperand &MO, const MachineRegisterInfo *MRI) {
517517
case RISCV::VWSUB_VV:
518518
case RISCV::VWSUB_VX:
519519
case RISCV::VWSLL_VI:
520+
case RISCV::VWSLL_VX:
521+
case RISCV::VWSLL_VV:
520522
// Vector Widening Integer Multiply Instructions
521523
// Destination EEW=2*SEW. Source EEW=SEW.
522524
case RISCV::VWMUL_VV:
@@ -1019,6 +1021,8 @@ static bool isSupportedInstr(const MachineInstr &MI) {
10191021

10201022
// Vector Crypto
10211023
case RISCV::VWSLL_VI:
1024+
case RISCV::VWSLL_VX:
1025+
case RISCV::VWSLL_VV:
10221026

10231027
// Vector Mask Instructions
10241028
// Vector Mask-Register Logical Instructions

llvm/test/CodeGen/RISCV/rvv/vl-opt-instrs.ll

Lines changed: 49 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3081,24 +3081,66 @@ define <vscale x 1 x i8> @vmv_v_v(<vscale x 1 x i8> %a, <vscale x 1 x i8> %b, <v
30813081
ret <vscale x 1 x i8> %3
30823082
}
30833083

3084-
define <vscale x 4 x i32> @vwsll_vi(<vscale x 4 x i16> %a, <vscale x 4 x i32> %b, iXLen %vl) {
3084+
define <vscale x 4 x i32> @vwsll_vi(<vscale x 4 x i16> %a, iXLen %vl) {
30853085
; NOVLOPT-LABEL: vwsll_vi:
30863086
; NOVLOPT: # %bb.0:
30873087
; NOVLOPT-NEXT: vsetvli a1, zero, e16, m1, ta, ma
3088-
; NOVLOPT-NEXT: vwsll.vi v12, v8, 1
3088+
; NOVLOPT-NEXT: vwsll.vi v10, v8, 1
30893089
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3090-
; NOVLOPT-NEXT: vadd.vv v8, v12, v10
3090+
; NOVLOPT-NEXT: vadd.vv v8, v10, v10
30913091
; NOVLOPT-NEXT: ret
30923092
;
30933093
; VLOPT-LABEL: vwsll_vi:
30943094
; VLOPT: # %bb.0:
30953095
; VLOPT-NEXT: vsetvli zero, a0, e16, m1, ta, ma
3096-
; VLOPT-NEXT: vwsll.vi v12, v8, 1
3096+
; VLOPT-NEXT: vwsll.vi v10, v8, 1
30973097
; VLOPT-NEXT: vsetvli zero, zero, e32, m2, ta, ma
3098-
; VLOPT-NEXT: vadd.vv v8, v12, v10
3098+
; VLOPT-NEXT: vadd.vv v8, v10, v10
30993099
; VLOPT-NEXT: ret
3100-
%1 = call <vscale x 4 x i32> @llvm.riscv.vwsll.nxv4i32.nxv4i16(<vscale x 4 x i32> poison, <vscale x 4 x i16> %a,iXLen 1, iXLen -1)
3101-
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %b, iXLen %vl)
3100+
%1 = call <vscale x 4 x i32> @llvm.riscv.vwsll.nxv4i32.nxv4i16(<vscale x 4 x i32> poison, <vscale x 4 x i16> %a, iXLen 1, iXLen -1)
3101+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %1, iXLen %vl)
3102+
ret <vscale x 4 x i32> %2
3103+
}
3104+
3105+
define <vscale x 4 x i32> @vwsll_vx(<vscale x 4 x i16> %a, iXLen %b, iXLen %vl) {
3106+
; NOVLOPT-LABEL: vwsll_vx:
3107+
; NOVLOPT: # %bb.0:
3108+
; NOVLOPT-NEXT: vsetvli a2, zero, e16, m1, ta, ma
3109+
; NOVLOPT-NEXT: vwsll.vx v10, v8, a0
3110+
; NOVLOPT-NEXT: vsetvli zero, a1, e32, m2, ta, ma
3111+
; NOVLOPT-NEXT: vadd.vv v8, v10, v10
3112+
; NOVLOPT-NEXT: ret
3113+
;
3114+
; VLOPT-LABEL: vwsll_vx:
3115+
; VLOPT: # %bb.0:
3116+
; VLOPT-NEXT: vsetvli zero, a1, e16, m1, ta, ma
3117+
; VLOPT-NEXT: vwsll.vx v10, v8, a0
3118+
; VLOPT-NEXT: vsetvli zero, zero, e32, m2, ta, ma
3119+
; VLOPT-NEXT: vadd.vv v8, v10, v10
3120+
; VLOPT-NEXT: ret
3121+
%1 = call <vscale x 4 x i32> @llvm.riscv.vwsll.nxv4i32.nxv4i16(<vscale x 4 x i32> poison, <vscale x 4 x i16> %a, iXLen %b, iXLen -1)
3122+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %1, iXLen %vl)
3123+
ret <vscale x 4 x i32> %2
3124+
}
3125+
3126+
define <vscale x 4 x i32> @vwsll_vv(<vscale x 4 x i16> %a, <vscale x 4 x i16> %b, iXLen %vl) {
3127+
; NOVLOPT-LABEL: vwsll_vv:
3128+
; NOVLOPT: # %bb.0:
3129+
; NOVLOPT-NEXT: vsetvli a1, zero, e16, m1, ta, ma
3130+
; NOVLOPT-NEXT: vwsll.vv v10, v8, v9
3131+
; NOVLOPT-NEXT: vsetvli zero, a0, e32, m2, ta, ma
3132+
; NOVLOPT-NEXT: vadd.vv v8, v10, v10
3133+
; NOVLOPT-NEXT: ret
3134+
;
3135+
; VLOPT-LABEL: vwsll_vv:
3136+
; VLOPT: # %bb.0:
3137+
; VLOPT-NEXT: vsetvli zero, a0, e16, m1, ta, ma
3138+
; VLOPT-NEXT: vwsll.vv v10, v8, v9
3139+
; VLOPT-NEXT: vsetvli zero, zero, e32, m2, ta, ma
3140+
; VLOPT-NEXT: vadd.vv v8, v10, v10
3141+
; VLOPT-NEXT: ret
3142+
%1 = call <vscale x 4 x i32> @llvm.riscv.vwsll.nxv4i32.nxv4i16(<vscale x 4 x i32> poison, <vscale x 4 x i16> %a, <vscale x 4 x i16> %b, iXLen -1)
3143+
%2 = call <vscale x 4 x i32> @llvm.riscv.vadd.nxv4i32.nxv4i32(<vscale x 4 x i32> poison, <vscale x 4 x i32> %1, <vscale x 4 x i32> %1, iXLen %vl)
31023144
ret <vscale x 4 x i32> %2
31033145
}
31043146

0 commit comments

Comments
 (0)