Bootstrapped / tested on x86_64-unknown-linux-gnu, applied.

Richard.

2017-01-30  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/79276
        * tree-vrp.c (process_assert_insertions): Properly adjust common
        when removing a duplicate.

        * gcc.dg/torture/pr79276.c: New testcase.

Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c      (revision 245022)
+++ gcc/tree-vrp.c      (working copy)
@@ -6544,6 +6544,11 @@ process_assert_insertions (void)
          else if (loc->e == asserts[j-1]->e)
            {
              /* Remove duplicate asserts.  */
+             if (commonj == j - 1)
+               {
+                 commonj = j;
+                 common = loc;
+               }
              free (asserts[j-1]);
              asserts[j-1] = NULL;
            }
Index: gcc/testsuite/gcc.dg/torture/pr79276.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr79276.c      (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr79276.c      (working copy)
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+
+short int
+ix (int *ld, short int oi)
+{
+  *ld = ((unsigned short int)oi | oi) && !!(*ld);
+  return (oi != 0) ? oi : 1;
+}

Reply via email to