https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106842

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
                 CC|                            |amacleod at redhat dot com

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
So I can confirm that the following avoids the bogus diagnostic on the GCC 12
branch but it will ICE when doing -fdump-tree-vrp-details like

t.c: In function 'main':
t.c:4:5: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in to_wide, at tree.h:6138
    4 | int main(int argc, char** argv)
      |     ^~~~
0x1889919 tree_class_check_failed(tree_node const*, tree_code_class, char
const*, int, char const*)
        /home/rguenther/src/gcc-12-branch/gcc/tree.cc:8869
0xae7151 tree_class_check(tree_node*, tree_code_class, char const*, int, char
const*)
        /home/rguenther/src/gcc-12-branch/gcc/tree.h:3580
0xb68f93 wi::to_wide(tree_node const*)
        /home/rguenther/src/gcc-12-branch/gcc/tree.h:6138
0xcdbc11 irange::upper_bound(unsigned int) const
        /home/rguenther/src/gcc-12-branch/gcc/value-range.h:535
0xcdbc81 irange::upper_bound() const
        /home/rguenther/src/gcc-12-branch/gcc/value-range.h:545
0x2ab34d3 operator_not_equal::op1_range(irange&, tree_node*, irange const&,
irange const&, tree_code) const
        /home/rguenther/src/gcc-12-branch/gcc/range-op.cc:713
0x2952cfd gimple_range_calc_op1(irange&, gimple const*, irange const&, irange
const&)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range-gori.cc:77
0x29558a8 gori_compute::compute_operand1_range(irange&, gimple*, irange const&,
tree_node*, fur_source&)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range-gori.cc:1024
0x295493c gori_compute::compute_operand_range(irange&, gimple*, irange const&,
tree_node*, fur_source&)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range-gori.cc:718
0x29566a2 gori_compute::outgoing_edge_range_p(irange&, edge_def*, tree_node*,
range_query&)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range-gori.cc:1271
0x294639e ranger_cache::range_on_edge(irange&, edge_def*, tree_node*)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range-cache.cc:1083
0x2942993 gimple_ranger::dump_bb(_IO_FILE*, basic_block_def*)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range.cc:550
0x2942c11 gimple_ranger::dump(_IO_FILE*)
        /home/rguenther/src/gcc-12-branch/gcc/gimple-range.cc:590
0x186618d execute_ranger_vrp(function*, bool)
        /home/rguenther/src/gcc-12-branch/gcc/tree-vrp.cc:4343

because we dump (and invoke range compute!) for unreachable blocks which
eventually runs into code with not up-to-date SSA form.  The patch should
save compile-time by not folding/substituting in regions that are not
reachable.

diff --git a/gcc/tree-ssa-propagate.cc b/gcc/tree-ssa-propagate.cc
index 976b035eeec..e669fc9b7cf 100644
--- a/gcc/tree-ssa-propagate.cc
+++ b/gcc/tree-ssa-propagate.cc
@@ -664,7 +664,7 @@ class substitute_and_fold_dom_walker : public dom_walker
 public:
     substitute_and_fold_dom_walker (cdi_direction direction,
                                    class substitute_and_fold_engine *engine)
-       : dom_walker (direction),
+       : dom_walker (direction, REACHABLE_BLOCKS),
           something_changed (false),
          substitute_and_fold_engine (engine)
     {
@@ -952,7 +952,7 @@ substitute_and_fold_dom_walker::before_dom_children
(basic_block bb)

   something_changed |= substitute_and_fold_engine->propagate_into_phi_args
(bb);

-  return NULL;
+  return find_taken_edge (bb, NULL_TREE);
 }

Reply via email to