On 12/1/21 15:34, Richard Biener wrote:
On Wed, Dec 1, 2021 at 3:25 PM Martin Liška <mli...@suse.cz> wrote:
On 12/1/21 15:19, Richard Biener wrote:
which is compute the range of 'lhs' on edge_true into predicate->true_range,
assign that same range to ->false_range and then invert it to get the
range on the false_edge. What I am saying is that for better precision
you should do
ranger->range_on_edge (predicate->false_range, edge_false, lhs);
rather than prematurely optimize this to the inversion of the true range
since yes, ranger is CFG sensitive and only the_last_ predicate on a
long CFG path is actually inverted.
What am I missing?
I might be misunderstood, but I think it's the problem defined here:
https://gcc.gnu.org/pipermail/gcc-patches/2021-November/584605.html
where I used the ranger->range_on_edge on the false_edge.
Ah, OK. But then even the true_edge range is possibly wrong, no?
You are of course correct, I've just proved that in debugger ://
Consider
for (;;)
{
if (a < 100)
if (a > 50) // unswitch on this
/* .. */
if (a < 120)
/* ... */
}
then you record [51, 99] for true_range of the a > 50 predicate and thus
simplification will simplify the if (a < 120) check, no?
Yep.
You can only record the range from the (CFG independent) a > 50 check,
thus [51, +INF] but of course at simplification time you can also use
the CFG context at each simplification location.
@Andrew: How can I easily get irange based just on a stmt? Something like
fold_range
with int_range_max as the 3rd argument?
Thanks,
Martin
Richard.
Martin