Skip to content

Commit

Permalink
RISC-V: Allow IMM operand for unsigned scalar .SAT_ADD
Browse files Browse the repository at this point in the history
This patch would like to allow the IMM operand of the unsigned
scalar .SAT_ADD.  Like the operand 0, the operand 1 of .SAT_ADD
will be zero extended to Xmode before underlying code generation.

The below test suites are passed for this patch.
* The rv64gcv fully regression test.

gcc/ChangeLog:

	* config/riscv/riscv.cc (riscv_expand_usadd): Zero extend
	the second operand of usadd as the first operand does.
	* config/riscv/riscv.md (usadd<m>3): Allow imm operand for
	scalar usadd pattern.

gcc/testsuite/ChangeLog:

	* gcc.target/riscv/sat_u_add-11.c: Make asm check robust.
	* gcc.target/riscv/sat_u_add-15.c: Ditto.
	* gcc.target/riscv/sat_u_add-19.c: Ditto.
	* gcc.target/riscv/sat_u_add-23.c: Ditto.
	* gcc.target/riscv/sat_u_add-3.c: Ditto.
	* gcc.target/riscv/sat_u_add-7.c: Ditto.

Signed-off-by: Pan Li <[email protected]>
  • Loading branch information
Incarnation-p-lee committed Sep 4, 2024
1 parent d8bc31d commit 9ea9d05
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gcc/config/riscv/riscv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11970,7 +11970,7 @@ riscv_expand_usadd (rtx dest, rtx x, rtx y)
rtx xmode_sum = gen_reg_rtx (Xmode);
rtx xmode_lt = gen_reg_rtx (Xmode);
rtx xmode_x = riscv_gen_zero_extend_rtx (x, mode);
rtx xmode_y = gen_lowpart (Xmode, y);
rtx xmode_y = riscv_gen_zero_extend_rtx (y, mode);
rtx xmode_dest = gen_reg_rtx (Xmode);

/* Step-1: sum = x + y */
Expand Down
4 changes: 2 additions & 2 deletions gcc/config/riscv/riscv.md
Original file line number Diff line number Diff line change
Expand Up @@ -4360,8 +4360,8 @@

(define_expand "usadd<mode>3"
[(match_operand:ANYI 0 "register_operand")
(match_operand:ANYI 1 "register_operand")
(match_operand:ANYI 2 "register_operand")]
(match_operand:ANYI 1 "reg_or_int_operand")
(match_operand:ANYI 2 "reg_or_int_operand")]
""
{
riscv_expand_usadd (operands[0], operands[1], operands[2]);
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-11.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_3:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-15.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_4:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-19.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_5:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-23.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_6:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-3.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_1:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down
2 changes: 1 addition & 1 deletion gcc/testsuite/gcc.target/riscv/sat_u_add-7.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
** sat_u_add_uint32_t_fmt_2:
** slli\s+[atx][0-9]+,\s*a0,\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** add\s+[atx][0-9]+,\s*a0,\s*a1
** add\s+[atx][0-9]+,\s*a[01],\s*a[01]
** slli\s+[atx][0-9]+,\s*[atx][0-9],\s*32
** srli\s+[atx][0-9]+,\s*[atx][0-9]+,\s*32
** sltu\s+[atx][0-9]+,\s*[atx][0-9]+,\s*[atx][0-9]+
Expand Down

0 comments on commit 9ea9d05

Please sign in to comment.