When adding the call to gen_vec_duplicate, I failed to notice that
code further down modified the VEC_DUPLICATE in place.  That isn't
safe if gen_vec_duplicate returned a const_vector.

Tested on x86_64-linux-gnu.  OK to install?

Thanks,
Richard


2017-11-02  Richard Sandiford  <richard.sandif...@linaro.org>

gcc/
        PR target/82809
        * config/i386/i386.c (ix86_vector_duplicate_value): Use
        gen_vec_duplicate after forcing the scalar into a register.

gcc/testsuite/
        * gcc.dg/pr82809.c: New test.

Index: gcc/config/i386/i386.c
===================================================================
--- gcc/config/i386/i386.c      2017-11-01 09:20:07.353478095 +0000
+++ gcc/config/i386/i386.c      2017-11-02 22:22:41.073913390 +0000
@@ -41232,7 +41232,7 @@ ix86_vector_duplicate_value (machine_mod
       reg = force_reg (innermode, val);
       if (GET_MODE (reg) != innermode)
        reg = gen_lowpart (innermode, reg);
-      XEXP (dup, 0) = reg;
+      SET_SRC (PATTERN (insn)) = gen_vec_duplicate (mode, reg);
       seq = get_insns ();
       end_sequence ();
       if (seq)
Index: gcc/testsuite/gcc.dg/pr82809.c
===================================================================
--- /dev/null   2017-11-02 18:54:18.211305311 +0000
+++ gcc/testsuite/gcc.dg/pr82809.c      2017-11-02 22:22:41.076914027 +0000
@@ -0,0 +1,22 @@
+/* { dg-do compile } */
+/* { dg-options "-Ofast -fno-tree-dominator-opts" } */
+
+struct locale_time_t
+{
+  const char *abday[7];
+  const unsigned int *wabday[7];
+};
+
+static const unsigned int empty_wstr[1] = { 0 };
+
+void
+time_read (struct locale_time_t *time)
+{
+  int cnt;
+
+  for (cnt=0; cnt < 7; cnt++)
+    {
+      time->abday[cnt] = "";
+      time->wabday[cnt] = empty_wstr;
+    }
+}

Reply via email to