Skip to content

Commit cc2dbf4

Browse files
committed
arcv: Fix missing vsetvli generation for arcv_vmv instructions.
The arcv_vmv RTL patterns were not generating vsetvli instructions because they lacked the proper RVV predication structure. This caused the vector configuration to not be set up before executing the arcv.vmv.v.s and arcv.vmv.s.v instructions. This patch restructures the arcv_vmv patterns to follow the standard RVV predicated instruction format by: - Wrapping the instruction in an if_then_else with UNSPEC_VPREDICATE. - Adding VL_REGNUM and VTYPE_REGNUM registers to the predication. - Moving the actual instruction logic to an inner unspec. This structure matches other ARCV vector instructions (like vnorm) and enables the vsetvl pass to properly insert vsetvli instructions before the arcv_vmv operations. Signed-off-by: Luis Silva <[email protected]>
1 parent b208250 commit cc2dbf4

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

gcc/config/riscv/arcv-vector.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,17 @@
139139

140140
(define_insn "@pred_arcv_vmv_v_s_scalar<V_VLSI:mode><P:mode>"
141141
[(set (match_operand:<V_VLSI:MODE> 0 "register_operand" "=vd, vd, vr, vr, vd, vd, vr, vr, vd, vd, vr, vr")
142-
(unspec:<V_VLSI:MODE>
143-
[(match_operand:V_VLSI 2 "register_operand" "vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr")
144-
(match_operand:P 3 "reg_or_int_operand" "r,r,r,r,r,r,i,i,i,i,i,i")
145-
(match_operand 4 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK")
146-
(match_operand 5 "const_int_operand" " i,i,i,i,i,i,i,i,i,i,i,i")
147-
(match_operand:<V_VLSI:MODE> 1 "register_operand" "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0")]
148-
UNSPEC_ARCV_VMV_V_S))]
142+
(if_then_else:<V_VLSI:MODE>
143+
(unspec:<V_VLSI:VM>
144+
[(match_operand 4 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK")
145+
(match_operand 5 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
146+
(reg:SI VL_REGNUM)
147+
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
148+
(unspec:<V_VLSI:MODE>
149+
[(match_operand:V_VLSI 2 "register_operand" "vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr")
150+
(match_operand:P 3 "reg_or_int_operand" "r,r,r,r,r,r,i,i,i,i,i,i")]
151+
UNSPEC_ARCV_VMV_V_S)
152+
(match_operand:<V_VLSI:MODE> 1 "register_operand" "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0")))]
149153
"TARGET_XARCVVDSP"
150154
{ return which_alternative < 6 ? "arcv.vmv.v.s\t%0,%2,%3" : "arcv.vmvi.v.s\t%0,%2,%3"; }
151155
[(set_attr "type" "viwmuladd")
@@ -157,13 +161,17 @@
157161

158162
(define_insn "@pred_arcv_vmv_s_v_scalar<V_VLSI:mode><P:mode>"
159163
[(set (match_operand:<V_LMUL1> 0 "register_operand" "=vd, vd, vr, vr, vd, vd, vr, vr, vd, vd, vr, vr")
160-
(unspec:<V_LMUL1>
161-
[(match_operand:V_VLSI 2 "register_operand" "vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr")
162-
(match_operand:P 3 "reg_or_int_operand" "r,r,r,r,r,r,i,i,i,i,i,i")
163-
(match_operand 4 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK")
164-
(match_operand 5 "const_int_operand" " i,i,i,i,i,i,i,i,i,i,i,i")
165-
(match_operand:<V_LMUL1> 1 "register_operand" "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0")]
166-
UNSPEC_ARCV_VMV_S_V))]
164+
(if_then_else:<V_LMUL1>
165+
(unspec:<V_VLSI:VM>
166+
[(match_operand 4 "vector_length_operand" " rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK, rK")
167+
(match_operand 5 "const_int_operand" " i, i, i, i, i, i, i, i, i, i, i, i")
168+
(reg:SI VL_REGNUM)
169+
(reg:SI VTYPE_REGNUM)] UNSPEC_VPREDICATE)
170+
(unspec:<V_LMUL1>
171+
[(match_operand:V_VLSI 2 "register_operand" "vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr,vr")
172+
(match_operand:P 3 "reg_or_int_operand" "r,r,r,r,r,r,i,i,i,i,i,i")]
173+
UNSPEC_ARCV_VMV_S_V)
174+
(match_operand:<V_LMUL1> 1 "register_operand" "0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0")))]
167175
"TARGET_XARCVVDSP"
168176
{ return which_alternative < 6 ? "arcv.vmv.s.v\t%0,%2,%3" : "arcv.vmvi.s.v\t%0,%2,%3"; }
169177
[(set_attr "type" "viwmuladd")

0 commit comments

Comments
 (0)