]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2012-10-01 Marc Glisse <marc.glisse@inria.fr>
authorglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Oct 2012 09:53:26 +0000 (09:53 +0000)
committerglisse <glisse@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 1 Oct 2012 09:53:26 +0000 (09:53 +0000)
gcc/
* simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>:
Detect the identity.
<VEC_CONCAT>: Handle VEC_SELECTs from the same vector.

gcc/testsuite/
* gcc.target/i386/vect-rebuild.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@191909 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/i386/vect-rebuild.c [new file with mode: 0644]

index 2acf70a3077a3390cc485a8df38cdf88bbc438b6..35c062c5979ad7a98b07ad108c997e97798a7303 100644 (file)
@@ -1,3 +1,9 @@
+2012-10-01  Marc Glisse  <marc.glisse@inria.fr>
+
+       * simplify-rtx.c (simplify_binary_operation_1) <VEC_SELECT>:
+       Detect the identity.
+       <VEC_CONCAT>: Handle VEC_SELECTs from the same vector.
+
 2012-10-01  Oleg Endo  <olegendo@gcc.gnu.org>
 
        PR target/50457
index af85ccc0836858895a4599be4386e6a1665d6bec..aebe6bbd93b9bb8d97ffb977ab199bb2c938df8d 100644 (file)
@@ -3246,6 +3246,23 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
              return gen_rtx_CONST_VECTOR (mode, v);
            }
 
+         /* Recognize the identity.  */
+         if (GET_MODE (trueop0) == mode)
+           {
+             bool maybe_ident = true;
+             for (int i = 0; i < XVECLEN (trueop1, 0); i++)
+               {
+                 rtx j = XVECEXP (trueop1, 0, i);
+                 if (!CONST_INT_P (j) || INTVAL (j) != i)
+                   {
+                     maybe_ident = false;
+                     break;
+                   }
+               }
+             if (maybe_ident)
+               return trueop0;
+           }
+
          /* If we build {a,b} then permute it, build the result directly.  */
          if (XVECLEN (trueop1, 0) == 2
              && CONST_INT_P (XVECEXP (trueop1, 0, 0))
@@ -3371,6 +3388,24 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
 
            return gen_rtx_CONST_VECTOR (mode, v);
          }
+
+       /* Try to merge VEC_SELECTs from the same vector into a single one.  */
+       if (GET_CODE (trueop0) == VEC_SELECT
+           && GET_CODE (trueop1) == VEC_SELECT
+           && rtx_equal_p (XEXP (trueop0, 0), XEXP (trueop1, 0)))
+         {
+           rtx par0 = XEXP (trueop0, 1);
+           rtx par1 = XEXP (trueop1, 1);
+           int len0 = XVECLEN (par0, 0);
+           int len1 = XVECLEN (par1, 0);
+           rtvec vec = rtvec_alloc (len0 + len1);
+           for (int i = 0; i < len0; i++)
+             RTVEC_ELT (vec, i) = XVECEXP (par0, 0, i);
+           for (int i = 0; i < len1; i++)
+             RTVEC_ELT (vec, len0 + i) = XVECEXP (par1, 0, i);
+           return simplify_gen_binary (VEC_SELECT, mode, XEXP (trueop0, 0),
+                                       gen_rtx_PARALLEL (VOIDmode, vec));
+         }
       }
       return 0;
 
index 8b0c58df86f8cc048999338f25c6bb5c53c3db00..aa9ddad7a842448b1750bbada7f71b2913acec96 100644 (file)
@@ -1,3 +1,7 @@
+2012-10-01  Marc Glisse  <marc.glisse@inria.fr>
+
+       * gcc.target/i386/vect-rebuild.c: New testcase.
+
 2012-09-30  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.target/i386/pad-10.c (foo2): Return x - z.
diff --git a/gcc/testsuite/gcc.target/i386/vect-rebuild.c b/gcc/testsuite/gcc.target/i386/vect-rebuild.c
new file mode 100644 (file)
index 0000000..570967f
--- /dev/null
@@ -0,0 +1,33 @@
+/* { dg-do compile } */
+/* { dg-options "-O -mavx -fno-tree-forwprop" } */
+
+typedef double v2df __attribute__ ((__vector_size__ (16)));
+typedef double v4df __attribute__ ((__vector_size__ (32)));
+
+v2df f1 (v2df x)
+{
+  v2df xx = { x[0], x[1] };
+  return xx;
+}
+
+v4df f2 (v4df x)
+{
+  v4df xx = { x[0], x[1], x[2], x[3] };
+  return xx;
+}
+
+v2df g (v2df x)
+{
+  v2df xx = { x[1], x[0] };
+  return xx;
+}
+
+v2df h (v4df x)
+{
+  v2df xx = { x[2], x[3] };
+  return xx;
+}
+
+/* { dg-final { scan-assembler-not "unpck" } } */
+/* { dg-final { scan-assembler-times "\tv?permilpd\[ \t\]" 1 } } */
+/* { dg-final { scan-assembler-times "\tv?extractf128\[ \t\]" 1 } } */