]> gcc.gnu.org Git - gcc.git/commitdiff
re PR tree-optimization/54471 (FAIL: gcc.dg/sms-8.c execution test)
authorJakub Jelinek <jakub@redhat.com>
Mon, 26 Nov 2012 09:19:30 +0000 (10:19 +0100)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 26 Nov 2012 09:19:30 +0000 (10:19 +0100)
PR tree-optimization/54471
* tree-vrp.c (extract_range_from_binary_expr_1): For MULT_EXPR,
don't canonicalize range if min2 is zero.

* gcc.dg/tree-ssa/vrp86.c: New test.
* gcc.c-torture/execute/pr54471.c: New test.

From-SVN: r193806

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/execute/pr54471.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/vrp86.c [new file with mode: 0644]
gcc/tree-vrp.c

index a682183fc7868036e34fa2c2d6f22cc47fb903f9..e58b1e66512ef2678ab65bad33ae5df410f5b60c 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54471
+       * tree-vrp.c (extract_range_from_binary_expr_1): For MULT_EXPR,
+       don't canonicalize range if min2 is zero.
+
 2012-11-26  Hans-Peter Nilsson  <hp@bitrange.com>
 
        PR middle-end/55030
index 320bd6473236efeb59b3b378e8342acea2462f5f..c8b4b6bf25f1416515848b7dd1181fcb1be26d47 100644 (file)
@@ -1,3 +1,9 @@
+2012-11-26  Jakub Jelinek  <jakub@redhat.com>
+
+       PR tree-optimization/54471
+       * gcc.dg/tree-ssa/vrp86.c: New test.
+       * gcc.c-torture/execute/pr54471.c: New test.
+
 2012-11-26  Hans-Peter Nilsson  <hp@bitrange.com>
 
        PR middle-end/55030
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr54471.c b/gcc/testsuite/gcc.c-torture/execute/pr54471.c
new file mode 100644 (file)
index 0000000..a169873
--- /dev/null
@@ -0,0 +1,36 @@
+/* PR tree-optimization/54471 */
+
+#ifdef __SIZEOF_INT128__
+#define T __int128
+#else
+#define T long long
+#endif
+
+extern void abort (void);
+
+__attribute__ ((noinline))
+unsigned T
+foo (T ixi, unsigned ctr)
+{
+  unsigned T irslt = 1;
+  T ix = ixi;
+
+  for (; ctr; ctr--)
+    {
+      irslt *= ix;
+      ix *= ix;
+    }
+
+  if (irslt != 14348907)
+    abort ();
+  return irslt;
+}
+
+int
+main ()
+{
+  unsigned T res;
+
+  res = foo (3, 4);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp86.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp86.c
new file mode 100644 (file)
index 0000000..ee7ed5f
--- /dev/null
@@ -0,0 +1,28 @@
+/* PR tree-optimization/54471 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-tree-vrp1" } */
+
+#ifdef __SIZEOF_INT128__
+#define T __int128
+#else
+#define T long long
+#endif
+
+void fn1call (void);
+void fn2call (void);
+
+void
+foo (unsigned T x)
+{
+  if (x > (unsigned T) -3)
+    return;
+  unsigned T y = 2 * x;
+  if (y == 42)
+    fn1call ();
+  else
+    fn2call ();
+}
+
+/* { dg-final { scan-tree-dump "fn1call" "vrp1"} } */
+/* { dg-final { scan-tree-dump "fn2call" "vrp1"} } */
+/* { dg-final { cleanup-tree-dump "vrp1" } } */
index 7f3e082446a8ded2d0834365abf758fee4e73b19..c9e4e313692fd98f3b54ed8fa6797a8c1101e049 100644 (file)
@@ -2653,7 +2653,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
          if (TYPE_UNSIGNED (expr_type))
            {
              double_int min2 = size - min0;
-             if (min2.cmp (max0, true) < 0)
+             if (!min2.is_zero () && min2.cmp (max0, true) < 0)
                {
                  min0 = -min2;
                  max0 -= size;
@@ -2661,7 +2661,7 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
                }
 
              min2 = size - min1;
-             if (min2.cmp (max1, true) < 0)
+             if (!min2.is_zero () && min2.cmp (max1, true) < 0)
                {
                  min1 = -min2;
                  max1 -= size;
This page took 0.124737 seconds and 5 git commands to generate.