PR target/99702: Check RTL type before get value
authorKito Cheng <kito.cheng@sifive.com>
Mon, 22 Mar 2021 08:32:45 +0000 (16:32 +0800)
committerKito Cheng <kito.cheng@sifive.com>
Mon, 22 Mar 2021 09:47:02 +0000 (17:47 +0800)
gcc/ChangeLog:

PR target/99702
* config/riscv/riscv.c (riscv_expand_block_move): Get RTL value
after type checking.

gcc/testsuite/ChangeLog:

PR target/99702
* gcc.target/riscv/pr99702.c: New.

gcc/config/riscv/riscv.c
gcc/testsuite/gcc.target/riscv/pr99702.c [new file with mode: 0644]

index 96fc0c0..de8308c 100644 (file)
@@ -3259,9 +3259,9 @@ riscv_block_move_loop (rtx dest, rtx src, unsigned HOST_WIDE_INT length,
 bool
 riscv_expand_block_move (rtx dest, rtx src, rtx length)
 {
-  unsigned HOST_WIDE_INT hwi_length = UINTVAL (length);
   if (CONST_INT_P (length))
     {
+      unsigned HOST_WIDE_INT hwi_length = UINTVAL (length);
       unsigned HOST_WIDE_INT factor, align;
 
       align = MIN (MIN (MEM_ALIGN (src), MEM_ALIGN (dest)), BITS_PER_WORD);
diff --git a/gcc/testsuite/gcc.target/riscv/pr99702.c b/gcc/testsuite/gcc.target/riscv/pr99702.c
new file mode 100644 (file)
index 0000000..a28724c
--- /dev/null
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-O" } */
+char n;
+void *i, *j;
+void foo(void) {
+  __builtin_memcpy(i, j, n);
+}