On Tue, Jun 10, 2025 at 10:51:25AM -0400, Andrew MacLeod wrote: > 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
So in that case --- gcc/gimple-range-fold.cc.jj 2025-04-30 18:19:09.914047199 +0200 +++ gcc/gimple-range-fold.cc 2025-06-10 19:50:25.537598812 +0200 @@ -51,6 +51,7 @@ along with GCC; see the file COPYING3. #include "sreal.h" #include "ipa-cp.h" #include "ipa-prop.h" +#include "rtl.h" // Construct a fur_source, and set the m_query field. fur_source::fur_source (range_query *q) @@ -778,11 +779,12 @@ fold_using_range::range_of_range_op (vra { basic_block bb = gimple_bb (s); edge e0 = EDGE_SUCC (bb, 0); - edge e1 = EDGE_SUCC (bb, 1); + edge e1 = single_succ_p (bb) ? NULL : EDGE_SUCC (bb, 1); + gcc_checking_assert (e1 || currently_expanding_to_rtl); if (!single_pred_p (e0->dest)) e0 = NULL; - if (!single_pred_p (e1->dest)) + if (e1 && !single_pred_p (e1->dest)) e1 = NULL; src.register_outgoing_edges (as_a<gcond *> (s), as_a <irange> (r), e0, e1); --- gcc/gimple-range-path.cc.jj 2025-01-02 20:54:32.236128440 +0100 +++ gcc/gimple-range-path.cc 2025-06-10 19:50:36.188457163 +0200 @@ -32,6 +32,7 @@ along with GCC; see the file COPYING3. #include "ssa.h" #include "tree-cfg.h" #include "gimple-iterator.h" +#include "rtl.h" // Internal construct to help facilitate debugging of solver. #define DEBUG_SOLVER (dump_file && (param_threader_debug == THREADER_DEBUG_ALL)) @@ -750,6 +751,11 @@ path_range_query::compute_outgoing_relat { if (gcond *cond = safe_dyn_cast <gcond *> (*gsi_last_bb (bb))) { + if (single_succ_p (bb)) + { + gcc_checking_assert (currently_expanding_to_rtl); + return; + } int_range<2> r; edge e0 = EDGE_SUCC (bb, 0); edge e1 = EDGE_SUCC (bb, 1); as incremental patch? Jakub