diff mbox series

[2/7] RISC-V: Fix uninitialized reg in memcpy

Message ID 20241018131300.1150819-3-craig.blackmore@embecosm.com
State New
Headers show
Series RISC-V: Vector memcpy/memset fixes and improvements | expand

Commit Message

Craig Blackmore Oct. 18, 2024, 1:12 p.m. UTC
riscv_vector::expand_block_move contains a gen_rtx_NE that uses
uninitialized reg rtx `end`.  It looks like `length_rtx` was supposed to
be used here.

gcc/ChangeLog:

	* config/riscv/riscv-string.cc (expand_block_move): Replace
	`end` with `length_rtx` in gen_rtx_NE.
---
 gcc/config/riscv/riscv-string.cc | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

Comments

Jeff Law Oct. 18, 2024, 3:07 p.m. UTC | #1
On 10/18/24 7:12 AM, Craig Blackmore wrote:
> gcc/ChangeLog:
> 
> 	* config/riscv/riscv-string.cc (expand_block_move): Replace
> 	`end` with `length_rtx` in gen_rtx_NE.
Thanks.  I've pushed this to the trunk.
jeff
diff mbox series

Patch

diff --git a/gcc/config/riscv/riscv-string.cc b/gcc/config/riscv/riscv-string.cc
index 0c5ffd7d861..0f1353baba3 100644
--- a/gcc/config/riscv/riscv-string.cc
+++ b/gcc/config/riscv/riscv-string.cc
@@ -1078,7 +1078,6 @@  expand_block_move (rtx dst_in, rtx src_in, rtx length_in)
   bool need_loop = true;
   bool size_p = optimize_function_for_size_p (cfun);
   rtx src, dst;
-  rtx end = gen_reg_rtx (Pmode);
   rtx vec;
   rtx length_rtx = length_in;
 
@@ -1245,7 +1244,7 @@  expand_block_move (rtx dst_in, rtx src_in, rtx length_in)
       emit_insn (gen_rtx_SET (length_rtx, gen_rtx_MINUS (Pmode, length_rtx, cnt)));
 
       /* Emit the loop condition.  */
-      rtx test = gen_rtx_NE (VOIDmode, end, const0_rtx);
+      rtx test = gen_rtx_NE (VOIDmode, length_rtx, const0_rtx);
       emit_jump_insn (gen_cbranch4 (Pmode, test, length_rtx, const0_rtx, label));
       emit_insn (gen_nop ());
     }