* [PATCH][1/2] Fix PR77768
@ 2016-09-28 11:37 Richard Biener
2016-09-29 7:12 ` Markus Trippelsdorf
0 siblings, 1 reply; 3+ messages in thread
From: Richard Biener @ 2016-09-28 11:37 UTC (permalink / raw)
To: gcc-patches
I am testing the following patch to avoid useless VRP range allocations
when we just ask for varying on stmts we don't know how to handle.
I think it should fix the PR where we end up assigning to the
static const vr_const_varying returned by get_value_range in the early VRP
context.
Eventually the VRP lattice needs to become sparse (or just growable, I
have a patch for that as well). Not until early VRP gets some more
capabilities though, it would be a waste otherwise.
Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.
Richard.
2016-09-28 Richard Biener <rguenther@suse.de>
* tree-vrp.c (set_defs_to_varying): New helper.
(vrp_initialize): Call it.
(vrp_visit_stmt): Likewise.
(evrp_dom_walker::before_dom_children): Likewise.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 240568)
+++ gcc/tree-vrp.c (working copy)
@@ -343,6 +343,24 @@ set_value_range_to_varying (value_range
}
+/* Set value-ranges of all SSA names defined by STMT to varying. */
+
+static void
+set_defs_to_varying (gimple *stmt)
+{
+ ssa_op_iter i;
+ tree def;
+ FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF)
+ {
+ unsigned ver = SSA_NAME_VERSION (def);
+ /* Avoid needlessly allocating value-ranges. */
+ if (num_vr_values >= ver
+ && vr_value[ver])
+ set_value_range_to_varying (vr_value[ver]);
+ }
+}
+
+
/* Set value range VR to {T, MIN, MAX, EQUIV}. */
static void
@@ -7022,10 +7040,7 @@ vrp_initialize ()
prop_set_simulate_again (stmt, true);
else if (!stmt_interesting_for_vrp (stmt))
{
- ssa_op_iter i;
- tree def;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
+ set_defs_to_varying (stmt);
prop_set_simulate_again (stmt, false);
}
else
@@ -7901,8 +7916,6 @@ vrp_visit_stmt (gimple *stmt, edge *take
{
value_range vr = VR_INITIALIZER;
tree lhs = gimple_get_lhs (stmt);
- tree def;
- ssa_op_iter iter;
extract_range_from_stmt (stmt, taken_edge_p, output_p, &vr);
if (*output_p)
@@ -7997,8 +8010,7 @@ vrp_visit_stmt (gimple *stmt, edge *take
/* All other statements produce nothing of interest for VRP, so mark
their outputs varying and prevent further simulation. */
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
+ set_defs_to_varying (stmt);
return (*taken_edge_p) ? SSA_PROP_INTERESTING : SSA_PROP_VARYING;
}
@@ -10726,12 +10738,7 @@ evrp_dom_walker::before_dom_children (ba
&& (vr.type == VR_RANGE || vr.type == VR_ANTI_RANGE))
update_value_range (output, &vr);
else
- {
- tree def;
- ssa_op_iter iter;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
- }
+ set_defs_to_varying (stmt);
/* Try folding stmts with the VR discovered. */
bool did_replace
@@ -10780,12 +10787,7 @@ evrp_dom_walker::before_dom_children (ba
}
}
else
- {
- tree def;
- ssa_op_iter iter;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
- }
+ set_defs_to_varying (stmt);
}
bb->flags |= BB_VISITED;
return NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][1/2] Fix PR77768
2016-09-28 11:37 [PATCH][1/2] Fix PR77768 Richard Biener
@ 2016-09-29 7:12 ` Markus Trippelsdorf
2016-09-29 7:36 ` Richard Biener
0 siblings, 1 reply; 3+ messages in thread
From: Markus Trippelsdorf @ 2016-09-29 7:12 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On 2016.09.28 at 13:33 +0200, Richard Biener wrote:
>
> I am testing the following patch to avoid useless VRP range allocations
> when we just ask for varying on stmts we don't know how to handle.
> I think it should fix the PR where we end up assigning to the
> static const vr_const_varying returned by get_value_range in the early VRP
> context.
>
> Eventually the VRP lattice needs to become sparse (or just growable, I
> have a patch for that as well). Not until early VRP gets some more
> capabilities though, it would be a waste otherwise.
>
> Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.
You probably noticed this yourself, but the patch causes conftests to
spin during stageprofile. For example libiberty:
configure:6516: checking for working fork
configure:6538: /home/trippels/gcc_build_dir_/./prev-gcc/xgcc -B/home/trippels/gcc_build_dir_/./prev-gcc/ -B/usr/local/powerpc64le-unknown-linux-gnu/bin/ -B/usr/local/powerpc64le-unknown-linux-gnu/bin/ -B/usr/local/powerpc64le-unknown-linux-gnu/lib/ -isystem /usr/local/powerpc64le-unknown-linux-gnu/include -isystem /usr/local/powerpc64le-unknown-linux-gnu/sys-include -o conftest -mcpu=power8 -O3 -pipe -gtoggle -fprofile-generate -static-libstdc++ -static-libgcc conftest.c >&5
configure:6538: $? = 0
configure:6538: ./conftest
<<spinning>>
--
Markus
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH][1/2] Fix PR77768
2016-09-29 7:12 ` Markus Trippelsdorf
@ 2016-09-29 7:36 ` Richard Biener
0 siblings, 0 replies; 3+ messages in thread
From: Richard Biener @ 2016-09-29 7:36 UTC (permalink / raw)
To: Markus Trippelsdorf; +Cc: gcc-patches
On Thu, 29 Sep 2016, Markus Trippelsdorf wrote:
> On 2016.09.28 at 13:33 +0200, Richard Biener wrote:
> >
> > I am testing the following patch to avoid useless VRP range allocations
> > when we just ask for varying on stmts we don't know how to handle.
> > I think it should fix the PR where we end up assigning to the
> > static const vr_const_varying returned by get_value_range in the early VRP
> > context.
> >
> > Eventually the VRP lattice needs to become sparse (or just growable, I
> > have a patch for that as well). Not until early VRP gets some more
> > capabilities though, it would be a waste otherwise.
> >
> > Bootstrap / regtest in progress on x86_64-unknown-linux-gnu.
>
> You probably noticed this yourself, but the patch causes conftests to
> spin during stageprofile. For example libiberty:
>
> configure:6516: checking for working fork
> configure:6538: /home/trippels/gcc_build_dir_/./prev-gcc/xgcc -B/home/trippels/gcc_build_dir_/./prev-gcc/ -B/usr/local/powerpc64le-unknown-linux-gnu/bin/ -B/usr/local/powerpc64le-unknown-linux-gnu/bin/ -B/usr/local/powerpc64le-unknown-linux-gnu/lib/ -isystem /usr/local/powerpc64le-unknown-linux-gnu/include -isystem /usr/local/powerpc64le-unknown-linux-gnu/sys-include -o conftest -mcpu=power8 -O3 -pipe -gtoggle -fprofile-generate -static-libstdc++ -static-libgcc conftest.c >&5
> configure:6538: $? = 0
> configure:6538: ./conftest
> <<spinning>>
I did. The following is what I have installed (not allocating the
ranges doesn't work - they end up UNDEFINED, but we can avoid storing
to already VR_VARYING ones).
Bootstrapped / tested on x86_64-unknown-linux-gnu, applied to trunk.
Richard.
2016-09-29 Richard Biener <rguenther@suse.de>
* tree-vrp.c (set_defs_to_varying): New helper avoiding
writing to vr_const_varying.
(vrp_initialize): Call it.
(vrp_visit_stmt): Likewise.
(evrp_dom_walker::before_dom_children): Likewise.
Index: gcc/tree-vrp.c
===================================================================
--- gcc/tree-vrp.c (revision 240568)
+++ gcc/tree-vrp.c (working copy)
@@ -710,6 +710,23 @@ get_value_range (const_tree var)
return vr;
}
+/* Set value-ranges of all SSA names defined by STMT to varying. */
+
+static void
+set_defs_to_varying (gimple *stmt)
+{
+ ssa_op_iter i;
+ tree def;
+ FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF)
+ {
+ value_range *vr = get_value_range (def);
+ /* Avoid writing to vr_const_varying get_value_range may return. */
+ if (vr->type != VR_VARYING)
+ set_value_range_to_varying (vr);
+ }
+}
+
+
/* Return true, if VAL1 and VAL2 are equal values for VRP purposes. */
static inline bool
@@ -7022,10 +7039,7 @@ vrp_initialize ()
prop_set_simulate_again (stmt, true);
else if (!stmt_interesting_for_vrp (stmt))
{
- ssa_op_iter i;
- tree def;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, i, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
+ set_defs_to_varying (stmt);
prop_set_simulate_again (stmt, false);
}
else
@@ -7901,8 +7915,6 @@ vrp_visit_stmt (gimple *stmt, edge *take
{
value_range vr = VR_INITIALIZER;
tree lhs = gimple_get_lhs (stmt);
- tree def;
- ssa_op_iter iter;
extract_range_from_stmt (stmt, taken_edge_p, output_p, &vr);
if (*output_p)
@@ -7997,8 +8009,7 @@ vrp_visit_stmt (gimple *stmt, edge *take
/* All other statements produce nothing of interest for VRP, so mark
their outputs varying and prevent further simulation. */
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
+ set_defs_to_varying (stmt);
return (*taken_edge_p) ? SSA_PROP_INTERESTING : SSA_PROP_VARYING;
}
@@ -10726,12 +10737,7 @@ evrp_dom_walker::before_dom_children (ba
&& (vr.type == VR_RANGE || vr.type == VR_ANTI_RANGE))
update_value_range (output, &vr);
else
- {
- tree def;
- ssa_op_iter iter;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
- }
+ set_defs_to_varying (stmt);
/* Try folding stmts with the VR discovered. */
bool did_replace
@@ -10780,12 +10786,7 @@ evrp_dom_walker::before_dom_children (ba
}
}
else
- {
- tree def;
- ssa_op_iter iter;
- FOR_EACH_SSA_TREE_OPERAND (def, stmt, iter, SSA_OP_DEF)
- set_value_range_to_varying (get_value_range (def));
- }
+ set_defs_to_varying (stmt);
}
bb->flags |= BB_VISITED;
return NULL;
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-09-29 7:12 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-28 11:37 [PATCH][1/2] Fix PR77768 Richard Biener
2016-09-29 7:12 ` Markus Trippelsdorf
2016-09-29 7:36 ` 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).