* [PATCH] Properly propagate into PHIs in forwprop
@ 2016-08-12 11:02 Richard Biener
0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2016-08-12 11:02 UTC (permalink / raw)
To: gcc-patches
forwprop has a lattice now (mainly for match-and-simplify simplification)
but it fails to substitute into PHIs or update the lattice for degenerate
PHIs. Fixed thusly.
Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
Richard.
2016-08-12 Richard Biener <rguenther@suse.de>
* tree-ssa-forwprop.c (pass_forwprop::execute): Propagate
into PHIs and update the lattice for its def.
Index: gcc/tree-ssa-forwprop.c
===================================================================
--- gcc/tree-ssa-forwprop.c (revision 239406)
+++ gcc/tree-ssa-forwprop.c (working copy)
@@ -2107,6 +2107,35 @@ pass_forwprop::execute (function *fun)
gimple_stmt_iterator gsi;
basic_block bb = BASIC_BLOCK_FOR_FN (fun, postorder[i]);
+ /* Propagate into PHIs and record degenerate ones in the lattice. */
+ for (gphi_iterator si = gsi_start_phis (bb); !gsi_end_p (si);
+ gsi_next (&si))
+ {
+ gphi *phi = si.phi ();
+ tree res = gimple_phi_result (phi);
+ if (virtual_operand_p (res))
+ continue;
+
+ use_operand_p use_p;
+ ssa_op_iter it;
+ tree first = NULL_TREE;
+ bool all_same = true;
+ FOR_EACH_PHI_ARG (use_p, phi, it, SSA_OP_USE)
+ {
+ tree use = USE_FROM_PTR (use_p);
+ tree tem = fwprop_ssa_val (use);
+ if (! first)
+ first = tem;
+ else if (! operand_equal_p (first, tem, 0))
+ all_same = false;
+ if (tem != use
+ && may_propagate_copy (use, tem))
+ propagate_value (use_p, tem);
+ }
+ if (all_same)
+ fwprop_set_lattice_val (res, first);
+ }
+
/* Apply forward propagation to all stmts in the basic-block.
Note we update GSI within the loop as necessary. */
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); )
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2016-08-12 11:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-12 11:02 [PATCH] Properly propagate into PHIs in forwprop Richard Biener
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).