* [tuples] fix thinkos in forwprop
@ 2008-06-30 18:26 Aldy Hernandez
2008-06-30 22:12 ` Richard Guenther
0 siblings, 1 reply; 5+ messages in thread
From: Aldy Hernandez @ 2008-06-30 18:26 UTC (permalink / raw)
To: dnovillo, gcc-patches
This fixes a handful of regressions caused by enabling forwprop.
Committed to branch.
* tree-ssa-forwprop.c: Remove obsolete comment.
(get_prop_source_stmt): Wrap call to gimple_assign_lhs with a
TREE_TYPE.
(forward_propagate_comparison): Use build2 instead of
fold_binary.
Index: tree-ssa-forwprop.c
===================================================================
--- tree-ssa-forwprop.c (revision 137150)
+++ tree-ssa-forwprop.c (working copy)
@@ -40,11 +40,6 @@ along with GCC; see the file COPYING3.
form of tree combination. It is hoped all of this can disappear
when we have a generalized tree combiner.
- Note carefully that after propagation the resulting statement
- must still be a proper gimple statement. Right now we simply
- only perform propagations we know will result in valid gimple
- code. One day we'll want to generalize this code.
-
One class of common cases we handle is forward propagating a single use
variable into a COND_EXPR.
@@ -239,7 +234,7 @@ get_prop_source_stmt (tree name, bool si
rhs = gimple_assign_rhs1 (def_stmt);
if (IS_CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
&& TREE_CODE (rhs) == SSA_NAME
- && POINTER_TYPE_P (gimple_assign_lhs (def_stmt))
+ && POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (def_stmt)))
&& POINTER_TYPE_P (TREE_TYPE (rhs)))
name = rhs;
else
@@ -970,13 +965,14 @@ forward_propagate_comparison (gimple stm
{
enum tree_code code = gimple_assign_rhs_code (use_stmt);
tree cst = gimple_assign_rhs2 (use_stmt);
+ tree cond;
+
+ cond = build2 (gimple_assign_rhs_code (stmt),
+ TREE_TYPE (cst),
+ gimple_assign_rhs1 (stmt),
+ gimple_assign_rhs2 (stmt));
- tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs),
- fold_binary (code,
- TREE_TYPE (cst),
- gimple_assign_rhs1 (stmt),
- gimple_assign_rhs2 (stmt)),
- cst, false);
+ tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs), cond, cst, false);
if (tmp == NULL_TREE)
return false;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tuples] fix thinkos in forwprop
2008-06-30 18:26 [tuples] fix thinkos in forwprop Aldy Hernandez
@ 2008-06-30 22:12 ` Richard Guenther
2008-06-30 22:18 ` Aldy Hernandez
0 siblings, 1 reply; 5+ messages in thread
From: Richard Guenther @ 2008-06-30 22:12 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: dnovillo, gcc-patches
On Mon, Jun 30, 2008 at 8:09 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> This fixes a handful of regressions caused by enabling forwprop.
>
> Committed to branch.
>
> * tree-ssa-forwprop.c: Remove obsolete comment.
> (get_prop_source_stmt): Wrap call to gimple_assign_lhs with a
> TREE_TYPE.
> (forward_propagate_comparison): Use build2 instead of
> fold_binary.
Why that? Trees should be always canonicalized.
Richard.
> Index: tree-ssa-forwprop.c
> ===================================================================
> --- tree-ssa-forwprop.c (revision 137150)
> +++ tree-ssa-forwprop.c (working copy)
> @@ -40,11 +40,6 @@ along with GCC; see the file COPYING3.
> form of tree combination. It is hoped all of this can disappear
> when we have a generalized tree combiner.
>
> - Note carefully that after propagation the resulting statement
> - must still be a proper gimple statement. Right now we simply
> - only perform propagations we know will result in valid gimple
> - code. One day we'll want to generalize this code.
> -
> One class of common cases we handle is forward propagating a single use
> variable into a COND_EXPR.
>
> @@ -239,7 +234,7 @@ get_prop_source_stmt (tree name, bool si
> rhs = gimple_assign_rhs1 (def_stmt);
> if (IS_CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def_stmt))
> && TREE_CODE (rhs) == SSA_NAME
> - && POINTER_TYPE_P (gimple_assign_lhs (def_stmt))
> + && POINTER_TYPE_P (TREE_TYPE (gimple_assign_lhs (def_stmt)))
> && POINTER_TYPE_P (TREE_TYPE (rhs)))
> name = rhs;
> else
> @@ -970,13 +965,14 @@ forward_propagate_comparison (gimple stm
> {
> enum tree_code code = gimple_assign_rhs_code (use_stmt);
> tree cst = gimple_assign_rhs2 (use_stmt);
> + tree cond;
> +
> + cond = build2 (gimple_assign_rhs_code (stmt),
> + TREE_TYPE (cst),
> + gimple_assign_rhs1 (stmt),
> + gimple_assign_rhs2 (stmt));
>
> - tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs),
> - fold_binary (code,
> - TREE_TYPE (cst),
> - gimple_assign_rhs1 (stmt),
> - gimple_assign_rhs2 (stmt)),
> - cst, false);
> + tmp = combine_cond_expr_cond (code, TREE_TYPE (lhs), cond, cst, false);
> if (tmp == NULL_TREE)
> return false;
> }
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tuples] fix thinkos in forwprop
2008-06-30 22:12 ` Richard Guenther
@ 2008-06-30 22:18 ` Aldy Hernandez
2008-06-30 22:23 ` Andrew Pinski
0 siblings, 1 reply; 5+ messages in thread
From: Aldy Hernandez @ 2008-06-30 22:18 UTC (permalink / raw)
To: Richard Guenther; +Cc: dnovillo, gcc-patches
On Tue, Jul 01, 2008 at 12:01:13AM +0200, Richard Guenther wrote:
> On Mon, Jun 30, 2008 at 8:09 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> > This fixes a handful of regressions caused by enabling forwprop.
> >
> > Committed to branch.
> >
> > * tree-ssa-forwprop.c: Remove obsolete comment.
> > (get_prop_source_stmt): Wrap call to gimple_assign_lhs with a
> > TREE_TYPE.
> > (forward_propagate_comparison): Use build2 instead of
> > fold_binary.
>
> Why that? Trees should be always canonicalized.
fold_binary was returning NULL because it couldn't do anything with a
testcase I found while boostrapping. I guess I could check the return
value from fold_binary-- and use build2 if fold_binary returns NULL.
I'll look into it.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tuples] fix thinkos in forwprop
2008-06-30 22:18 ` Aldy Hernandez
@ 2008-06-30 22:23 ` Andrew Pinski
2008-07-02 12:24 ` Aldy Hernandez
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Pinski @ 2008-06-30 22:23 UTC (permalink / raw)
To: Aldy Hernandez; +Cc: Richard Guenther, dnovillo, gcc-patches
On Mon, Jun 30, 2008 at 3:12 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> fold_binary was returning NULL because it couldn't do anything with a
> testcase I found while boostrapping. I guess I could check the return
> value from fold_binary-- and use build2 if fold_binary returns NULL.
Or better just use fold_build2 which does that already :).
-- Pinski
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [tuples] fix thinkos in forwprop
2008-06-30 22:23 ` Andrew Pinski
@ 2008-07-02 12:24 ` Aldy Hernandez
0 siblings, 0 replies; 5+ messages in thread
From: Aldy Hernandez @ 2008-07-02 12:24 UTC (permalink / raw)
To: Andrew Pinski; +Cc: Richard Guenther, dnovillo, gcc-patches
On Mon, Jun 30, 2008 at 03:17:40PM -0700, Andrew Pinski wrote:
> On Mon, Jun 30, 2008 at 3:12 PM, Aldy Hernandez <aldyh@redhat.com> wrote:
> > fold_binary was returning NULL because it couldn't do anything with a
> > testcase I found while boostrapping. I guess I could check the return
> > value from fold_binary-- and use build2 if fold_binary returns NULL.
>
> Or better just use fold_build2 which does that already :).
Heh. Did not know about this. I'll use it.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-02 11:58 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-30 18:26 [tuples] fix thinkos in forwprop Aldy Hernandez
2008-06-30 22:12 ` Richard Guenther
2008-06-30 22:18 ` Aldy Hernandez
2008-06-30 22:23 ` Andrew Pinski
2008-07-02 12:24 ` Aldy Hernandez
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).