This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[committed] Fix SSE1 V4SImode vector insert (PR target/69551)


Hi!

The following patch fixes a bug in the V4SImode ix86_expand_vector_set
SSE1 handling, before we recurse, we need to copy the original target
to the temporary, otherwise we set just the single element and leave
the rest of the elements uninitialized.

Bootstrapped/regtested on x86_64-linux and i686-linux, preapproved
by Uros in the PR, committed to trunk and 5.x so far.

2016-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR target/69551
	* config/i386/i386.c (ix86_expand_vector_set) <case V4SImode>: For
	SSE1, copy target into the temporary reg first before recursing
	on it.

	* gcc.target/i386/pr69551.c: New test.

--- gcc/config/i386/i386.c.jj	2016-01-28 15:07:25.000000000 +0100
+++ gcc/config/i386/i386.c	2016-01-29 13:02:32.100788474 +0100
@@ -46744,6 +46744,7 @@ ix86_expand_vector_set (bool mmx_ok, rtx
 	{
 	  /* For SSE1, we have to reuse the V4SF code.  */
 	  rtx t = gen_reg_rtx (V4SFmode);
+	  emit_move_insn (t, gen_lowpart (V4SFmode, target));
 	  ix86_expand_vector_set (false, t, gen_lowpart (SFmode, val), elt);
 	  emit_move_insn (target, gen_lowpart (mode, t));
 	}
--- gcc/testsuite/gcc.target/i386/pr69551.c.jj	2016-01-29 13:10:46.338993771 +0100
+++ gcc/testsuite/gcc.target/i386/pr69551.c	2016-01-29 13:09:49.000000000 +0100
@@ -0,0 +1,23 @@
+/* PR target/69551 */
+/* { dg-do run { target sse_runtime } } */
+/* { dg-options "-O2 -mno-sse2 -msse" } */
+
+typedef unsigned char v16qi __attribute__ ((vector_size (16)));
+typedef unsigned int v4si __attribute__ ((vector_size (16)));
+
+char __attribute__ ((noinline, noclone))
+test (v4si vec)
+{
+  vec[1] = 0x5fb856;
+  return ((v16qi) vec)[0];
+}
+
+int
+main ()
+{
+  char z = test ((v4si) { -1, -1, -1, -1 });
+
+  if (z != -1)
+    __builtin_abort ();
+  return 0;
+}

	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]