From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6D75B3858421; Tue, 20 Dec 2022 15:23:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6D75B3858421 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1671549807; bh=YyeCOKpX3JfjP+Nq6LWIEPIUg5okZfUhXvxFpag1vGY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=F/hpKPhB+X3dgjDqVnlm5mRvrhF4GLmW3eEWfwtoU/6f+bzAAdO0xgXrFdLCt6IYS SoGtFcShFenMhCe4Z1vJNzouDQJIvmNPs3266vtWJW4b8M0AE0lEd3aWtrLuqBmWUJ 8cLhlT0fzXwoZmG1BiplJOUSuObSqRjKJoo110PA= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/106842] [12/13 Regression] misleading warning : iteration X invokes undefined behavior Date: Tue, 20 Dec 2022 15:23:26 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 12.2.1 X-Bugzilla-Keywords: diagnostic, missed-optimization, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: priority cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D106842 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P3 |P2 CC| |amacleod at redhat dot com --- Comment #6 from Richard Biener --- 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, ch= ar 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&, iran= ge const&) /home/rguenther/src/gcc-12-branch/gcc/gimple-range-gori.cc:77 0x29558a8 gori_compute::compute_operand1_range(irange&, gimple*, irange con= st&, 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 cons= t&, 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 *engin= e) - : 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 |=3D substitute_and_fold_engine->propagate_into_phi_ar= gs (bb); - return NULL; + return find_taken_edge (bb, NULL_TREE); }=