2009-11-04 Richard Guenther <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Nov 2009 10:18:33 +0000 (10:18 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 4 Nov 2009 10:18:33 +0000 (10:18 +0000)
PR tree-optimization/41919
* tree-vrp.c (test_for_singularity): Properly compare values.

* gcc.c-torture/execute/pr41919.c: New testcase.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153891 138bc75d-0d04-0410-961f-82ee72b054a4

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

index 0187c43..38a584a 100644 (file)
@@ -1,3 +1,8 @@
+2009-11-04  Richard Guenther  <rguenther@suse.de>
+
+       PR tree-optimization/41919
+       * gcc.c-torture/execute/pr41919.c: New testcase.
+
 2009-11-04  Carlos O'Donell  <carlos@codesourcery.com>
 
        PR target/41302
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr41919.c b/gcc/testsuite/gcc.c-torture/execute/pr41919.c
new file mode 100644 (file)
index 0000000..4ca0914
--- /dev/null
@@ -0,0 +1,39 @@
+extern void abort (void);
+
+#define assert(x) if(!(x)) abort()
+
+struct S1
+{
+  char f0;
+};
+
+int g_23 = 0;
+
+static struct S1
+foo (void)
+{
+  int *l_100 = &g_23;
+  int **l_110 = &l_100;
+  struct S1 l_128 = { 1 };
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  assert (l_100 == &g_23);
+  return l_128;
+}
+
+static char bar(char si1, char si2)
+{
+  return (si1 <= 0) ? si1 : (si2 * 2);
+}
+int main (void)
+{
+  struct S1 s = foo();
+  if (bar(0x99 ^ (s.f0 && 1), 1) != -104)
+    abort ();
+  return 0;
+}
+
index 0cb227a..5adc0da 100644 (file)
@@ -6748,13 +6748,9 @@ test_for_singularity (enum tree_code cond_code, tree op0,
      value range information we have for op0.  */
   if (min && max)
     {
-      if (compare_values (vr->min, min) == -1)
-       min = min;
-      else
+      if (compare_values (vr->min, min) == 1)
        min = vr->min;
-      if (compare_values (vr->max, max) == 1)
-       max = max;
-      else
+      if (compare_values (vr->max, max) == -1)
        max = vr->max;
 
       /* If the new min/max values have converged to a single value,