On 6/10/25 10:07, Jakub Jelinek wrote:
On Tue, Jun 10, 2025 at 09:59:33AM -0400, Andrew MacLeod wrote:
Yes, there are places , particularly fold_using_range in
gimple-range-fold.cc, which expects there to be 2 edges to a GCOND stmt.
it always expects 2 successors. There are not many places like that, many
simply look at the specified edge of a gcond... but the few there are
could also be adjusted pretty easily to check if the edge is there before
doing anything...
Yeah, I've noticed that GCOND case before I've deferred cleaning of the
EDGE_TRUE_VALUE and EDGE_FALSE_VALUE flags from the GCOND edges.
Now those are cleared later but for the 1 removed edge I don't have a
testcase.
That was the
gcc_checking_assert (e->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE));
assert failing in gcond_edge_range. But I don't see where it would now
assume there must be 2 edges rather than just one of those,
gcond_edge_range simply has to be called on some edges and it can't be
called on an edge which doesn't exist. If it is called on the remaining
edge which still has either EDGE_TRUE_VALUE or EDGE_FALSE_VALUE flag set,
it should properly get the range from that edge depending on if it is
for true or false condition.
Jakub
Edge range should be fine, and really that assert doesnt really need to
be there.
Where the issue could arise is in gimple-range-fold.cc in
fold_using_range::range_of_range_op() where we see something like:
else if (is_a<gcond *> (s) && gimple_bb (s))
{
basic_block bb = gimple_bb (s);
edge e0 = EDGE_SUCC (bb, 0);
edge e1 = EDGE_SUCC (bb, 1);
if (!single_pred_p (e0->dest))
e0 = NULL;
if (!single_pred_p (e1->dest))
e1 = NULL;
src.register_outgoing_edges (as_a<gcond *> (s),
as_a <irange> (r), e0, e1);
Althogh, now that I look at it, it doesn't need much adjustment, just
the expectation that there are 2 edges. I suppose EDGE_SUCC (bb, 1)
cpould potentially trap if there is only one edge. we'd just have to
guard it and alloow for that case
Andrew