OSDN Git Service

PR tree-optimization/53410
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 May 2012 21:00:43 +0000 (21:00 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 21 May 2012 21:00:43 +0000 (21:00 +0000)
* fold-const.c (fold_binary_loc): Use build_zero_cst (type)
instead of build_int_cst (type, 0) where vector types might be
involved.

* gcc.c-torture/compile/pr53410-1.c: New test.
* gcc.c-torture/compile/pr53410-2.c: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@187738 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/fold-const.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/pr53410-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/compile/pr53410-2.c [new file with mode: 0644]

index 1acd665..82d93b3 100644 (file)
@@ -1,3 +1,10 @@
+2012-05-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/53410
+       * fold-const.c (fold_binary_loc): Use build_zero_cst (type)
+       instead of build_int_cst (type, 0) where vector types might be
+       involved.
+
 2012-05-21  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/53418
index 6874c9e..13f22d6 100644 (file)
@@ -12828,13 +12828,13 @@ fold_binary_loc (location_t loc,
       if (TREE_CODE (arg0) == BIT_XOR_EXPR
          && operand_equal_p (TREE_OPERAND (arg0, 1), arg1, 0))
        return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 0),
-                               build_int_cst (TREE_TYPE (arg0), 0));
+                               build_zero_cst (TREE_TYPE (arg0)));
       /* Likewise (X ^ Y) == X becomes Y == 0.  X has no side-effects.  */
       if (TREE_CODE (arg0) == BIT_XOR_EXPR
          && operand_equal_p (TREE_OPERAND (arg0, 0), arg1, 0)
          && reorder_operands_p (TREE_OPERAND (arg0, 1), arg1))
        return fold_build2_loc (loc, code, type, TREE_OPERAND (arg0, 1),
-                               build_int_cst (TREE_TYPE (arg0), 0));
+                               build_zero_cst (TREE_TYPE (arg0)));
 
       /* (X ^ C1) op C2 can be rewritten as X op (C1 ^ C2).  */
       if (TREE_CODE (arg0) == BIT_XOR_EXPR
@@ -12922,7 +12922,7 @@ fold_binary_loc (location_t loc,
                                                          BIT_XOR_EXPR, itype,
                                                          arg00, arg10),
                                             arg01),
-                               build_int_cst (itype, 0));
+                               build_zero_cst (itype));
 
          if (operand_equal_p (arg01, arg10, 0))
            return fold_build2_loc (loc, code, type,
@@ -12931,7 +12931,7 @@ fold_binary_loc (location_t loc,
                                                          BIT_XOR_EXPR, itype,
                                                          arg00, arg11),
                                             arg01),
-                               build_int_cst (itype, 0));
+                               build_zero_cst (itype));
 
          if (operand_equal_p (arg00, arg11, 0))
            return fold_build2_loc (loc, code, type,
@@ -12940,7 +12940,7 @@ fold_binary_loc (location_t loc,
                                                          BIT_XOR_EXPR, itype,
                                                          arg01, arg10),
                                             arg00),
-                               build_int_cst (itype, 0));
+                               build_zero_cst (itype));
 
          if (operand_equal_p (arg00, arg10, 0))
            return fold_build2_loc (loc, code, type,
@@ -12949,7 +12949,7 @@ fold_binary_loc (location_t loc,
                                                          BIT_XOR_EXPR, itype,
                                                          arg01, arg11),
                                             arg00),
-                               build_int_cst (itype, 0));
+                               build_zero_cst (itype));
        }
 
       if (TREE_CODE (arg0) == BIT_XOR_EXPR
index 3bdea30..2580956 100644 (file)
@@ -1,3 +1,9 @@
+2012-05-21  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/53410
+       * gcc.c-torture/compile/pr53410-1.c: New test.
+       * gcc.c-torture/compile/pr53410-2.c: New test.
+
 2012-05-21  Joseph Myers  <joseph@codesourcery.com>
 
        PR c/53418
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr53410-1.c b/gcc/testsuite/gcc.c-torture/compile/pr53410-1.c
new file mode 100644 (file)
index 0000000..48a014e
--- /dev/null
@@ -0,0 +1,10 @@
+/* PR tree-optimization/53410 */
+
+int *a, b, c, d;
+
+void
+foo (void)
+{
+  for (; d <= 0; d++)
+    b &= ((a || d) ^ c) == 1;
+}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr53410-2.c b/gcc/testsuite/gcc.c-torture/compile/pr53410-2.c
new file mode 100644 (file)
index 0000000..06aa7fe
--- /dev/null
@@ -0,0 +1,64 @@
+/* PR tree-optimization/53410 */
+
+typedef int V __attribute__((vector_size (4 * sizeof (int))));
+typedef unsigned int W __attribute__((vector_size (4 * sizeof (int))));
+
+void
+f1 (V *p)
+{
+  *p = (*p & ((V) { 1, 1, 1, 1 })) ^ ((V) { 1, 1, 1, 1});
+}
+
+void
+f2 (V *p)
+{
+  *p = (*p ^ ((V) { 1, 1, 1, 1 })) & ((V) { 1, 1, 1, 1});
+}
+
+void
+f3 (V *p)
+{
+  *p = (~*p) & ((V) { 1, 1, 1, 1 });
+}
+
+void
+f4 (V *p, V *q)
+{
+  *p = (*p ^ *q) == *q;
+}
+
+void
+f5 (V *p, V *q)
+{
+  *p = (*p ^ *q) == *p;
+}
+
+void
+f6 (V *p, V *q, V *r)
+{
+  *p = (*p & *r) == (*q & *r);
+}
+
+void
+f7 (V *p, V *q, V *r)
+{
+  *p = (*p & *r) == (*r & *q);
+}
+
+void
+f8 (V *p, V *q, V *r)
+{
+  *p = (*r & *p) == (*q & *r);
+}
+
+void
+f9 (V *p, V *q, V *r)
+{
+  *p = (*r & *p) == (*r & *q);
+}
+
+void
+f10 (W *p, W *q)
+{
+  *p = *p < (((const W) { 1U, 1U, 1U, 1U }) << *q);
+}