[PATCH] Fix gather expansion (PR target/59839)

Jakub Jelinek jakub@redhat.com
Thu Jan 16 19:06:00 GMT 2014


Hi!

As the following testcase shows, if target of a gather intrinsic
is e.g. a MEM, we shouldn't use it as target, because it fails
the output operand predicate.

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.8?

2014-01-16  Jakub Jelinek  <jakub@redhat.com>

	PR target/59839
	* config/i386/i386.c (ix86_expand_builtin): If target doesn't
	satisfy operand 0 predicate for gathers, use a new pseudo as
	subtarget.

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

--- gcc/config/i386/i386.c.jj	2014-01-16 09:41:19.000000000 +0100
+++ gcc/config/i386/i386.c	2014-01-16 14:32:35.796844336 +0100
@@ -35511,7 +35511,9 @@ addcarryx:
       mode4 = insn_data[icode].operand[5].mode;
 
       if (target == NULL_RTX
-	  || GET_MODE (target) != insn_data[icode].operand[0].mode)
+	  || GET_MODE (target) != insn_data[icode].operand[0].mode
+	  || !insn_data[icode].operand[0].predicate (target,
+						     GET_MODE (target)))
 	subtarget = gen_reg_rtx (insn_data[icode].operand[0].mode);
       else
 	subtarget = target;
--- gcc/testsuite/gcc.target/i386/pr59839.c.jj	2014-01-16 14:29:34.936767655 +0100
+++ gcc/testsuite/gcc.target/i386/pr59839.c	2014-01-16 14:29:07.000000000 +0100
@@ -0,0 +1,12 @@
+/* PR target/59839 */
+/* { dg-do compile } */
+/* { dg-options "-O0 -mavx2" } */
+
+#include <x86intrin.h>
+
+void
+test (const float *x)
+{
+  __m256i i = _mm256_set1_epi32 (1);
+  __m256 d = _mm256_i32gather_ps (x, i, 1);
+}

	Jakub



More information about the Gcc-patches mailing list