]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[simplify-rtx] PR 65235: Calculate element size correctly when simplifying (vec_selec...
authorKyrylo Tkachov <kyrylo.tkachov@arm.com>
Thu, 19 Mar 2015 09:58:42 +0000 (09:58 +0000)
committerKyrylo Tkachov <ktkachov@gcc.gnu.org>
Thu, 19 Mar 2015 09:58:42 +0000 (09:58 +0000)
Backport from mainline
2015-03-12  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>

PR rtl-optimization/65235
* simplify-rtx.c (simplify_binary_operation_1, VEC_SELECT case):
When first element of vec_concat is const_int, calculate its size
using second element.

PR rtl-optimization/65235
* gcc.target/aarch64/pr65235_1.c: New test.

From-SVN: r221511

gcc/ChangeLog
gcc/simplify-rtx.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/pr65235_1.c [new file with mode: 0644]

index 1553638a7f0c864568e1309c525fa0ce1954532b..e77ea88836a39dde4fe8dd7909105b388b28e129 100644 (file)
@@ -1,3 +1,13 @@
+2015-03-19  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       Backport from mainline
+       2015-03-12  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/65235
+       * simplify-rtx.c (simplify_binary_operation_1, VEC_SELECT case):
+       When first element of vec_concat is const_int, calculate its size
+       using second element.
+
 2015-03-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        PR middle-end/65409
index 04af01e6ea2420bc0a93326f2c7870176e523f7e..037adefa779e3a2facaed9983e62a2f06c0d3657 100644 (file)
@@ -3633,7 +3633,21 @@ simplify_binary_operation_1 (enum rtx_code code, enum machine_mode mode,
          while (GET_MODE (vec) != mode
                 && GET_CODE (vec) == VEC_CONCAT)
            {
-             HOST_WIDE_INT vec_size = GET_MODE_SIZE (GET_MODE (XEXP (vec, 0)));
+             HOST_WIDE_INT vec_size;
+
+             if (CONST_INT_P (XEXP (vec, 0)))
+               {
+                 /* vec_concat of two const_ints doesn't make sense with
+                    respect to modes.  */
+                 if (CONST_INT_P (XEXP (vec, 1)))
+                   return 0;
+
+                 vec_size = GET_MODE_SIZE (GET_MODE (trueop0))
+                            - GET_MODE_SIZE (GET_MODE (XEXP (vec, 1)));
+               }
+             else
+               vec_size = GET_MODE_SIZE (GET_MODE (XEXP (vec, 0)));
+
              if (offset < vec_size)
                vec = XEXP (vec, 0);
              else
index d3beb1f270fb81a00fe91750972c887ff9ac740d..7f79d7dc4b3aa1c1d8bd1e299c853d1dc19ab755 100644 (file)
@@ -1,3 +1,11 @@
+2015-03-19  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       Backport from mainline
+       2015-03-12  Kyrylo Tkachov  <kyrylo.tkachov@arm.com>
+
+       PR rtl-optimization/65235
+       * gcc.target/aarch64/pr65235_1.c: New test.
+
 2015-03-16  Eric Botcazou  <ebotcazou@adacore.com>
 
        * testsuite/g++.dg/pr65049.C: New test.
diff --git a/gcc/testsuite/gcc.target/aarch64/pr65235_1.c b/gcc/testsuite/gcc.target/aarch64/pr65235_1.c
new file mode 100644 (file)
index 0000000..ca12cd5
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#include "arm_neon.h"
+
+int
+main (int argc, char** argv)
+{
+  int64x1_t val1;
+  int64x1_t val2;
+  int64x1_t val3;
+  uint64x1_t val13;
+  uint64x2_t val14;
+  uint64_t got;
+  uint64_t exp;
+  val1 = vcreate_s64(UINT64_C(0xffffffff80008000));
+  val2 = vcreate_s64(UINT64_C(0x0000f38d00000000));
+  val3 = vcreate_s64(UINT64_C(0xffff7fff0000809b));
+  /* Expect: "val13" = 8000000000001553.  */
+  val13 = vcreate_u64 (UINT64_C(0x8000000000001553));
+  /* Expect: "val14" = 0010 0000 0000 0002 0000 0000 0000 0000.  */
+  val14 = vcombine_u64(vcgt_s64(vqrshl_s64(val1, val2),
+                               vshr_n_s64(val3, 18)),
+                      vshr_n_u64(val13, 11));
+  /* Should be 0000000000000000.  */
+  got = vgetq_lane_u64(val14, 0);
+  exp = 0;
+  if(exp != got)
+    __builtin_abort ();
+}