I noticed while improving cselim-limited that if
not creating a new phi, there are a few empty basic blocks.
So this sets cfgcleanup when cselim-limited does
something in phiopt. cselim-5.c shows the case I
was looking into.
gcc/ChangeLog:
* tree-ssa-phiopt.cc (pass_phiopt::execute): Set cfgcleanup
if cselim_limited returns true.
gcc/testsuite/ChangeLog:
* gcc.dg/tree-ssa/cselim-5.c: New test.
Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-phiopt1" } */
+
+int t;
+void f(int a, int b, int c, int d)
+{
+ if (b)
+ t = 0;
+ else
+ t = 0;
+}
+
+/* We should sink/merge the stores and end up with a single BB. */
+
+/* { dg-final { scan-tree-dump-times "t = 0;" 1 "phiopt1" } } */
+/* { dg-final { scan-tree-dump-times "<bb " 1 "phiopt1" } } */
hoist_adjacent_loads (bb, bb1, bb2, bb3);
/* Try to see if there are only store in each side of the if
- and try to remove that; don't do this for -Og. */
+ and try to remove that; don't do this for -Og.
+ With sinking the stores we might end up with empty blocks. */
if (EDGE_COUNT (bb3->preds) == 2 && !optimize_debug)
while (cond_if_else_store_replacement_limited (bb1, bb2, bb3))
- ;
+ cfgchanged = true;
}
gimple_stmt_iterator gsi;