On aarch64 -milp32, and presumably on other such targets, ptr can be
in a different mode than ptr_mode in the testcase.  Cope with it.

Regstrapped on x86_64-linux-gnu, also tested the new test on
aarch64-elf.  Ok to install?


for  gcc/ChangeLog

        PR target/112804
        * builtins.cc (try_store_by_multiple_pieces): Use ptr's mode
        for the increment.

for  gcc/testsuite/ChangeLog

        PR target/112804
        * gcc.target/aarch64/inline-mem-set-pr112804.c: New.
---
 gcc/builtins.cc                                    |    2 +-
 .../gcc.target/aarch64/inline-mem-set-pr112804.c   |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
 create mode 100644 gcc/testsuite/gcc.target/aarch64/inline-mem-set-pr112804.c

diff --git a/gcc/builtins.cc b/gcc/builtins.cc
index 38b0acff13124..12a535d313f12 100644
--- a/gcc/builtins.cc
+++ b/gcc/builtins.cc
@@ -4519,7 +4519,7 @@ try_store_by_multiple_pieces (rtx to, rtx len, unsigned 
int ctz_len,
          to = change_address (to, QImode, 0);
          emit_move_insn (to, val);
          if (update_needed)
-           next_ptr = plus_constant (ptr_mode, ptr, blksize);
+           next_ptr = plus_constant (GET_MODE (ptr), ptr, blksize);
        }
       else
        {
diff --git a/gcc/testsuite/gcc.target/aarch64/inline-mem-set-pr112804.c 
b/gcc/testsuite/gcc.target/aarch64/inline-mem-set-pr112804.c
new file mode 100644
index 0000000000000..fe8414559864d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/aarch64/inline-mem-set-pr112804.c
@@ -0,0 +1,7 @@
+/* { dg-do compile } */
+/* { dg-options "-finline-stringops -mabi=ilp32 -ftrivial-auto-var-init=zero" 
} */
+
+short m(unsigned k) {
+  const unsigned short *n[65];
+  return 0;
+}

-- 
Alexandre Oliva, happy hacker            https://FSFLA.org/blogs/lxo/
   Free Software Activist                   GNU Toolchain Engineer
More tolerance and less prejudice are key for inclusion and diversity
Excluding neuro-others for not behaving ""normal"" is *not* inclusive

Reply via email to