OSDN Git Service

Backported from mainline
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 May 2014 16:08:28 +0000 (16:08 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 7 May 2014 16:08:28 +0000 (16:08 +0000)
2013-11-27  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/59014
* gcc.c-torture/execute/pr59014-2.c: New test.

2013-11-26  Jakub Jelinek  <jakub@redhat.com>

PR tree-optimization/59014
* tree-vrp.c (register_edge_assert_for_1): Don't look
through conversions from non-integral types or through
narrowing conversions.

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

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

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr59014-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr59014.c [new file with mode: 0644]
gcc/tree-vrp.c

index 7105500..c32f181 100644 (file)
@@ -1,6 +1,13 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/59014
+       * tree-vrp.c (register_edge_assert_for_1): Don't look
+       through conversions from non-integral types or through
+       narrowing conversions.
+
        2013-11-14  Jakub Jelinek  <jakub@redhat.com>
                    Uros Bizjak  <ubizjak@gmail.com>
 
        2013-11-14  Jakub Jelinek  <jakub@redhat.com>
                    Uros Bizjak  <ubizjak@gmail.com>
 
index bc5ef8f..4307f71 100644 (file)
@@ -1,6 +1,16 @@
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
 2014-05-07  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2013-11-27  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/59014
+       * gcc.c-torture/execute/pr59014-2.c: New test.
+
+       2013-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/59014
+       * gcc.c-torture/execute/pr59014.c: New test.
+
        2013-11-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/59101
        2013-11-14  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/59101
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c b/gcc/testsuite/gcc.c-torture/execute/pr59014-2.c
new file mode 100644 (file)
index 0000000..18da005
--- /dev/null
@@ -0,0 +1,23 @@
+/* PR tree-optimization/59014 */
+
+__attribute__((noinline, noclone)) long long int
+foo (long long int x, long long int y)
+{
+  if (((int) x | (int) y) != 0)
+    return 6;
+  return x + y;
+}
+
+int
+main ()
+{
+  if (sizeof (long long) == sizeof (int))
+    return 0;
+  int shift_half = sizeof (int) * __CHAR_BIT__ / 2;
+  long long int x = (3LL << shift_half) << shift_half;
+  long long int y = (5LL << shift_half) << shift_half;
+  long long int z = foo (x, y);
+  if (z != ((8LL << shift_half) << shift_half))
+    __builtin_abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr59014.c b/gcc/testsuite/gcc.c-torture/execute/pr59014.c
new file mode 100644 (file)
index 0000000..10bf81a
--- /dev/null
@@ -0,0 +1,25 @@
+/* PR tree-optimization/59014 */
+
+int a = 2, b, c, d;
+
+int
+foo ()
+{
+  for (;; c++)
+    if ((b > 0) | (a & 1))
+      ;
+    else
+      {
+       d = a;
+       return 0;
+      }
+}
+
+int
+main ()
+{
+  foo ();
+  if (d != 2)
+    __builtin_abort ();
+  return 0;
+}
index a65266c..1bb1775 100644 (file)
@@ -4536,9 +4536,13 @@ register_edge_assert_for_1 (tree op, enum tree_code code,
     }
   else if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (op_def)))
     {
     }
   else if (CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (op_def)))
     {
-      /* Recurse through the type conversion.  */
-      retval |= register_edge_assert_for_1 (gimple_assign_rhs1 (op_def),
-                                           code, e, bsi);
+      /* Recurse through the type conversion, unless it is a narrowing
+        conversion or conversion from non-integral type.  */
+      tree rhs = gimple_assign_rhs1 (op_def);
+      if (INTEGRAL_TYPE_P (TREE_TYPE (rhs))
+         && (TYPE_PRECISION (TREE_TYPE (rhs))
+             <= TYPE_PRECISION (TREE_TYPE (op))))
+       retval |= register_edge_assert_for_1 (rhs, code, e, bsi);
     }
 
   return retval;
     }
 
   return retval;