]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR tree-optimization/60960 (Wrong result when a vector variable is divid...
authorJakub Jelinek <jakub@redhat.com>
Mon, 5 May 2014 08:16:43 +0000 (10:16 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 5 May 2014 08:16:43 +0000 (10:16 +0200)
Backported from mainline
2014-04-25  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/60960
* tree-vect-generic.c (expand_vector_operation): Only call
expand_vector_divmod if type's mode satisfies VECTOR_MODE_P.

* gcc.c-torture/execute/pr60960.c: New test.

From-SVN: r210064

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr60960.c [new file with mode: 0644]
gcc/tree-vect-generic.c

index aab20ca12205dd29cf73af1e05374dacf9465755..f4de0bcd86c274f00cbd5c092bfc69b5627b2d8d 100644 (file)
@@ -1,3 +1,12 @@
+2014-05-05  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2014-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/60960
+       * tree-vect-generic.c (expand_vector_operation): Only call
+       expand_vector_divmod if type's mode satisfies VECTOR_MODE_P.
+
 2014-05-04  Peter Bergner  <bergner@vnet.ibm.com>
 
        * config/rs6000/rs6000.h (RS6000_BTM_HARD_FLOAT): New define.
index 3f0d9ce1c55c904e2406c18016029485b991dad7..8cb497d966e178d8afee1a11b40767a433297638 100644 (file)
@@ -1,3 +1,11 @@
+2014-05-05  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       2014-04-25  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/60960
+       * gcc.c-torture/execute/pr60960.c: New test.
+
 2014-05-04  Peter Bergner  <bergner@vnet.ibm.com>
 
        * gcc.target/powerpc/pack02.c (dg-options): Add -mhard-float.
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr60960.c b/gcc/testsuite/gcc.c-torture/execute/pr60960.c
new file mode 100644 (file)
index 0000000..b4f08d4
--- /dev/null
@@ -0,0 +1,38 @@
+/* PR tree-optimization/60960 */
+
+typedef unsigned char v4qi __attribute__ ((vector_size (4)));
+
+__attribute__((noinline, noclone)) v4qi
+f1 (v4qi v)
+{
+  return v / 2;
+}
+
+__attribute__((noinline, noclone)) v4qi
+f2 (v4qi v)
+{
+  return v / (v4qi) { 2, 2, 2, 2 };
+}
+
+__attribute__((noinline, noclone)) v4qi
+f3 (v4qi x, v4qi y)
+{
+  return x / y;
+}
+
+int
+main ()
+{
+  v4qi x = { 5, 5, 5, 5 };
+  v4qi y = { 2, 2, 2, 2 };
+  v4qi z = f1 (x);
+  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+    __builtin_abort ();
+  z = f2 (x);
+  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+    __builtin_abort ();
+  z = f3 (x, y);
+  if (__builtin_memcmp (&y, &z, sizeof (y)) != 0)
+    __builtin_abort ();
+  return 0;
+}
index b53ccd1c875b2635038e1f785559d2175393e041..2aed6f1fd690d959d038dbf0269295109d4efcf9 100644 (file)
@@ -1006,7 +1006,8 @@ expand_vector_operation (gimple_stmt_iterator *gsi, tree type, tree compute_type
 
          if (!optimize
              || !VECTOR_INTEGER_TYPE_P (type)
-             || TREE_CODE (rhs2) != VECTOR_CST)
+             || TREE_CODE (rhs2) != VECTOR_CST
+             || !VECTOR_MODE_P (TYPE_MODE (type)))
            break;
 
          ret = expand_vector_divmod (gsi, type, rhs1, rhs2, code);