re PR tree-optimization/67769 (VRP pass does wrong optimization)
authorMarek Polacek <polacek@redhat.com>
Thu, 1 Oct 2015 14:25:42 +0000 (14:25 +0000)
committerMarek Polacek <mpolacek@gcc.gnu.org>
Thu, 1 Oct 2015 14:25:42 +0000 (14:25 +0000)
PR tree-optimization/67769
* tree-ssa-phiopt.c (conditional_replacement): Call
reset_flow_sensitive_info_in_bb.
(minmax_replacement): Likewise.
(abs_replacement): Likewise.

* gcc.dg/torture/pr67769.c: New test.

From-SVN: r228341

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr67769.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c

index 06c9a298153a323f625de22388e510ce6a4bd6d6..c9f987ea81519409be1d235dbae19f32e1667367 100644 (file)
@@ -1,3 +1,11 @@
+2015-10-01  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/67769
+       * tree-ssa-phiopt.c (conditional_replacement): Call
+       reset_flow_sensitive_info_in_bb.
+       (minmax_replacement): Likewise.
+       (abs_replacement): Likewise.
+
 2015-10-01  Nathan Sidwell  <nathan@codesourcery.com>
 
        * builtins.c: Don't include gomp-constants.h.
index 4b5d14761a307a61e0950d3085bff7c0a67071a7..1d4713d6799eafbc29fa493a527e6b2103846048 100644 (file)
@@ -1,3 +1,8 @@
+2015-10-01  Marek Polacek  <polacek@redhat.com>
+
+       PR tree-optimization/67769
+       * gcc.dg/torture/pr67769.c: New test.
+
 2015-10-01  Uros Bizjak  <ubizjak@gmail.com>
 
        * gcc.dg/lto/pr55113_0.c: Skip on all x86 targets.
diff --git a/gcc/testsuite/gcc.dg/torture/pr67769.c b/gcc/testsuite/gcc.dg/torture/pr67769.c
new file mode 100644 (file)
index 0000000..c1d17c3
--- /dev/null
@@ -0,0 +1,23 @@
+/* { dg-do run } */
+
+static int
+clamp (int x, int lo, int hi)
+{
+  return (x < lo) ? lo : ((x > hi) ? hi : x);
+}
+
+__attribute__ ((noinline))
+short
+foo (int N)
+{
+  short value = clamp (N, 0, 16);
+  return value;
+}
+
+int
+main ()
+{
+  if (foo (-5) != 0)
+    __builtin_abort ();
+  return 0;
+}
index 37fdf28d31b98c0368776b71a1173ff277ee5870..697836a3c146d511d68f388f8503cc1d19337160 100644 (file)
@@ -646,6 +646,7 @@ conditional_replacement (basic_block cond_bb, basic_block middle_bb,
     }
 
   replace_phi_edge_with_variable (cond_bb, e1, phi, new_var);
+  reset_flow_sensitive_info_in_bb (cond_bb);
 
   /* Note that we optimized this PHI.  */
   return true;
@@ -1284,6 +1285,8 @@ minmax_replacement (basic_block cond_bb, basic_block middle_bb,
   gsi_insert_before (&gsi, new_stmt, GSI_NEW_STMT);
 
   replace_phi_edge_with_variable (cond_bb, e1, phi, result);
+  reset_flow_sensitive_info_in_bb (cond_bb);
+
   return true;
 }
 
@@ -1402,6 +1405,7 @@ abs_replacement (basic_block cond_bb, basic_block middle_bb,
     }
 
   replace_phi_edge_with_variable (cond_bb, e1, phi, result);
+  reset_flow_sensitive_info_in_bb (cond_bb);
 
   /* Note that we optimized this PHI.  */
   return true;