* [PATCH] Fix reassoc update_range_test (PR tree-optimization/62209)
@ 2015-02-13 19:48 Jakub Jelinek
2015-02-14 7:40 ` Richard Biener
0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2015-02-13 19:48 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
Hi!
With LTO and -O0 initial compilation, -O1 linking we at some point used to
add stmts normal after a PHI, which is invalid.
This patch fixes that by inserting after labels instead.
No testcase provided, as the issue is latent anyway and I don't know how to
write lto testcases that use different options initially from linking
options.
Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
2015-02-13 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/62209
* tree-ssa-reassoc.c (update_range_test): If stmt is a PHI and
op == range->exp, insert seq and gimplified code after labels
instead of after the phi.
--- gcc/tree-ssa-reassoc.c.jj 2015-02-13 15:02:03.000000000 +0100
+++ gcc/tree-ssa-reassoc.c 2015-02-13 16:52:05.113232491 +0100
@@ -2160,10 +2160,18 @@ update_range_test (struct range_entry *r
tem = fold_convert_loc (loc, optype, tem);
gsi = gsi_for_stmt (stmt);
+ unsigned int uid = gimple_uid (stmt);
/* In rare cases range->exp can be equal to lhs of stmt.
In that case we have to insert after the stmt rather then before
- it. */
- if (op == range->exp)
+ it. If stmt is a PHI, insert it at the start of the basic block. */
+ if (op != range->exp)
+ {
+ gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
+ tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
+ GSI_SAME_STMT);
+ gsi_prev (&gsi);
+ }
+ else if (gimple_code (stmt) != GIMPLE_PHI)
{
gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false,
@@ -2171,16 +2179,32 @@ update_range_test (struct range_entry *r
}
else
{
+ gsi = gsi_after_labels (gimple_bb (stmt));
+ if (!gsi_end_p (gsi))
+ uid = gimple_uid (gsi_stmt (gsi));
+ else
+ {
+ gsi = gsi_start_bb (gimple_bb (stmt));
+ uid = 1;
+ while (!gsi_end_p (gsi))
+ {
+ uid = gimple_uid (gsi_stmt (gsi));
+ gsi_next (&gsi);
+ }
+ }
gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
GSI_SAME_STMT);
- gsi_prev (&gsi);
+ if (gsi_end_p (gsi))
+ gsi = gsi_last_bb (gimple_bb (stmt));
+ else
+ gsi_prev (&gsi);
}
for (; !gsi_end_p (gsi); gsi_prev (&gsi))
if (gimple_uid (gsi_stmt (gsi)))
break;
else
- gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt));
+ gimple_set_uid (gsi_stmt (gsi), uid);
oe->op = tem;
range->exp = exp;
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix reassoc update_range_test (PR tree-optimization/62209)
2015-02-13 19:48 [PATCH] Fix reassoc update_range_test (PR tree-optimization/62209) Jakub Jelinek
@ 2015-02-14 7:40 ` Richard Biener
0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2015-02-14 7:40 UTC (permalink / raw)
To: Jakub Jelinek; +Cc: gcc-patches
On February 13, 2015 8:48:25 PM CET, Jakub Jelinek <jakub@redhat.com> wrote:
>Hi!
>
>With LTO and -O0 initial compilation, -O1 linking we at some point used
>to
>add stmts normal after a PHI, which is invalid.
>This patch fixes that by inserting after labels instead.
>No testcase provided, as the issue is latent anyway and I don't know
>how to
>write lto testcases that use different options initially from linking
>options.
>
>Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
OK.
Thanks,
Richard.
>2015-02-13 Jakub Jelinek <jakub@redhat.com>
>
> PR tree-optimization/62209
> * tree-ssa-reassoc.c (update_range_test): If stmt is a PHI and
> op == range->exp, insert seq and gimplified code after labels
> instead of after the phi.
>
>--- gcc/tree-ssa-reassoc.c.jj 2015-02-13 15:02:03.000000000 +0100
>+++ gcc/tree-ssa-reassoc.c 2015-02-13 16:52:05.113232491 +0100
>@@ -2160,10 +2160,18 @@ update_range_test (struct range_entry *r
>
> tem = fold_convert_loc (loc, optype, tem);
> gsi = gsi_for_stmt (stmt);
>+ unsigned int uid = gimple_uid (stmt);
> /* In rare cases range->exp can be equal to lhs of stmt.
> In that case we have to insert after the stmt rather then before
>- it. */
>- if (op == range->exp)
>+ it. If stmt is a PHI, insert it at the start of the basic block.
> */
>+ if (op != range->exp)
>+ {
>+ gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
>+ tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE,
>true,
>+ GSI_SAME_STMT);
>+ gsi_prev (&gsi);
>+ }
>+ else if (gimple_code (stmt) != GIMPLE_PHI)
> {
> gsi_insert_seq_after (&gsi, seq, GSI_CONTINUE_LINKING);
> tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, false,
>@@ -2171,16 +2179,32 @@ update_range_test (struct range_entry *r
> }
> else
> {
>+ gsi = gsi_after_labels (gimple_bb (stmt));
>+ if (!gsi_end_p (gsi))
>+ uid = gimple_uid (gsi_stmt (gsi));
>+ else
>+ {
>+ gsi = gsi_start_bb (gimple_bb (stmt));
>+ uid = 1;
>+ while (!gsi_end_p (gsi))
>+ {
>+ uid = gimple_uid (gsi_stmt (gsi));
>+ gsi_next (&gsi);
>+ }
>+ }
> gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
> tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
> GSI_SAME_STMT);
>- gsi_prev (&gsi);
>+ if (gsi_end_p (gsi))
>+ gsi = gsi_last_bb (gimple_bb (stmt));
>+ else
>+ gsi_prev (&gsi);
> }
> for (; !gsi_end_p (gsi); gsi_prev (&gsi))
> if (gimple_uid (gsi_stmt (gsi)))
> break;
> else
>- gimple_set_uid (gsi_stmt (gsi), gimple_uid (stmt));
>+ gimple_set_uid (gsi_stmt (gsi), uid);
>
> oe->op = tem;
> range->exp = exp;
>
> Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-02-14 7:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-13 19:48 [PATCH] Fix reassoc update_range_test (PR tree-optimization/62209) Jakub Jelinek
2015-02-14 7:40 ` 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).