Message ID | BANLkTinVngFyW42-LP7CqadCbFXuym6rCw@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Tue, 2011-05-24 at 16:44 +0200, Richard Guenther wrote: > On Tue, May 24, 2011 at 3:38 PM, William J. Schmidt > <wschmidt@linux.vnet.ibm.com> wrote: > > > > On Tue, 2011-05-24 at 15:11 +0200, Richard Guenther wrote: > >> On Tue, May 24, 2011 at 2:26 PM, William J. Schmidt > >> <wschmidt@linux.vnet.ibm.com> wrote: > >> > Sure, I'll give that a try this morning. Much obliged. > >> > >> Seems it won't work that way without some major changes elsewhere. > >> Instead follow what update_call_from_tree () does before calling > >> gsi_replace. > > > > Bother. This won't work, unfortunately. I can't use gimple_set_vuse () > > and gimple_set_vdef () on statements without memory ops. > > You should do > > if (!gimple_has_mem_ops (new_stmt)) > unlink_stmt_vdef (old_stmt); OK, thanks, that's the interface I was struggling to find. That solved the issue I ran into. The handling for powi now looks like this: CASE_FLT_FN (BUILT_IN_POWI): arg0 = gimple_call_arg (stmt, 0); arg1 = gimple_call_arg (stmt, 1); if (!host_integerp (arg1, 0)) break; n = TREE_INT_CST_LOW (arg1); loc = gimple_location (stmt); result = gimple_expand_builtin_powi (&gsi, loc, arg0, n); if (result) { tree lhs = gimple_get_lhs (stmt); gimple new_stmt = gimple_build_assign (lhs, result); gimple_set_location (new_stmt, loc); move_ssa_defining_stmt_for_defs (new_stmt, stmt); if (gimple_vdef (stmt)) { gcc_assert (!gimple_has_mem_ops (new_stmt)); unlink_stmt_vdef (stmt); } gsi_replace (&gsi, new_stmt, true); } break; gimple_has_mem_ops (new_stmt) will always return false. The assert is in place in case we add other powi transforms in the future. The call to move_ssa_defining_stmt_for_defs requires adding the header file tree-ssa-propagate.h, and the corresponding dependency in Makefile.in. Currently regression testing the "final" fix. Let me know if you want to see it one more time before commit. Thanks as always for your help! Bill > > > Bill > > > >> > >> Richard. > >> > > > > > >
On Tue, May 24, 2011 at 5:28 PM, William J. Schmidt <wschmidt@linux.vnet.ibm.com> wrote: > > On Tue, 2011-05-24 at 16:44 +0200, Richard Guenther wrote: >> On Tue, May 24, 2011 at 3:38 PM, William J. Schmidt >> <wschmidt@linux.vnet.ibm.com> wrote: >> > >> > On Tue, 2011-05-24 at 15:11 +0200, Richard Guenther wrote: >> >> On Tue, May 24, 2011 at 2:26 PM, William J. Schmidt >> >> <wschmidt@linux.vnet.ibm.com> wrote: >> >> > Sure, I'll give that a try this morning. Much obliged. >> >> >> >> Seems it won't work that way without some major changes elsewhere. >> >> Instead follow what update_call_from_tree () does before calling >> >> gsi_replace. >> > >> > Bother. This won't work, unfortunately. I can't use gimple_set_vuse () >> > and gimple_set_vdef () on statements without memory ops. >> >> You should do >> >> if (!gimple_has_mem_ops (new_stmt)) >> unlink_stmt_vdef (old_stmt); > > OK, thanks, that's the interface I was struggling to find. > > That solved the issue I ran into. The handling for powi now looks like > this: > > CASE_FLT_FN (BUILT_IN_POWI): > arg0 = gimple_call_arg (stmt, 0); > arg1 = gimple_call_arg (stmt, 1); > if (!host_integerp (arg1, 0)) > break; > > n = TREE_INT_CST_LOW (arg1); > loc = gimple_location (stmt); > result = gimple_expand_builtin_powi (&gsi, loc, arg0, n); > > if (result) > { > tree lhs = gimple_get_lhs (stmt); > gimple new_stmt = gimple_build_assign (lhs, result); > gimple_set_location (new_stmt, loc); > move_ssa_defining_stmt_for_defs (new_stmt, stmt); > > if (gimple_vdef (stmt)) > { > gcc_assert (!gimple_has_mem_ops (new_stmt)); > unlink_stmt_vdef (stmt); > } As you say the new stmt will not have mem-ops, so move_ssa_defining_stmt_for_defs is not necessary. Likewise you can simply unconditionally call unlink_stmt_vdef. > gsi_replace (&gsi, new_stmt, true); > } > break; > > gimple_has_mem_ops (new_stmt) will always return false. The assert is > in place in case we add other powi transforms in the future. > > The call to move_ssa_defining_stmt_for_defs requires adding the header > file tree-ssa-propagate.h, and the corresponding dependency in > Makefile.in. > > Currently regression testing the "final" fix. Let me know if you want > to see it one more time before commit. It's ok with the above two changes. Thanks, Richard. > Thanks as always for your help! > > Bill > >> >> > Bill >> > >> >> >> >> Richard. >> >> >> > >> > >> > > >
Index: gcc/gimple-iterator.c =================================================================== --- gcc/gimple-iterator.c (revision 174106) +++ gcc/gimple-iterator.c (working copy) @@ -394,6 +394,7 @@ void gsi_replace (gimple_stmt_iterator *gsi, gimple stmt, bool update_eh_info) { gimple orig_stmt = gsi_stmt (*gsi); + tree vop; if (stmt == orig_stmt) return; @@ -409,6 +410,13 @@ gsi_replace (gimple_stmt_iterator *gsi, if (update_eh_info) maybe_clean_or_replace_eh_stmt (orig_stmt, stmt); + /* Preserve virtual operands from the original statement, they will + be dropped by update_stmt if they are not necessary. */ + if ((vop = gimple_vdef (orig_stmt)) != NULL_TREE) + gimple_set_vdef (stmt, vop); + if ((vop = gimple_vuse (orig_stmt)) != NULL_TREE) + gimple_set_vuse (stmt, vop); + gimple_duplicate_stmt_histograms (cfun, stmt, cfun, orig_stmt); /* Free all the data flow information for ORIG_STMT. */