From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 973A63853D6D; Tue, 29 Nov 2022 11:59:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 973A63853D6D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669723172; bh=c9RSMQ+USV1WJ9SH0FOVoKkNcx3McFHv5OvASt1J7UE=; h=From:To:Subject:Date:From; b=wFsoU01m/XZxAOmhp4EMhavfQleZyx3c4UdRITzmmVqnWJyA34WY1bk7YgGJvl7pK c2BizdPwTHgclHH8GGXIzMyVquCXBwDCTHXyFtGj7w2neX66kBm+ixRUWDpNUi9ICN vFdknB7D5EiZCexRvZPCVVIguWZcGGKzaJoIFjZI= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4388] tree-optimization/106995 - if-conversion and vanishing loops X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: ffabce849033e57ebaf60029822b81e981681c21 X-Git-Newrev: 063ba138eaa15ceecf23a24906e0e19be98d509d Message-Id: <20221129115932.973A63853D6D@sourceware.org> Date: Tue, 29 Nov 2022 11:59:32 +0000 (GMT) List-Id: https://gcc.gnu.org/g:063ba138eaa15ceecf23a24906e0e19be98d509d commit r13-4388-g063ba138eaa15ceecf23a24906e0e19be98d509d Author: Richard Biener Date: Tue Nov 29 10:41:36 2022 +0100 tree-optimization/106995 - if-conversion and vanishing loops When we version loops for vectorization during if-conversion it can happen that either loop vanishes because we run some VN and CFG cleanup. If the to-be vectorized part vanishes we already redirect the versioning condition to the original loop. The following does the same in case the original loop vanishes as happened for the testcase in the bug in the past (but no longer). PR tree-optimization/106995 * tree-if-conv.cc (pass_if_conversion::execute): Also redirect the versioning condition to the original loop if this very loop vanished during CFG cleanup. Diff: --- gcc/tree-if-conv.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/tree-if-conv.cc b/gcc/tree-if-conv.cc index 34bb507ff3b..64b20b4a9e1 100644 --- a/gcc/tree-if-conv.cc +++ b/gcc/tree-if-conv.cc @@ -3761,7 +3761,8 @@ pass_if_conversion::execute (function *fun) if (!gimple_bb (g)) continue; unsigned ifcvt_loop = tree_to_uhwi (gimple_call_arg (g, 0)); - if (!get_loop (fun, ifcvt_loop)) + unsigned orig_loop = tree_to_uhwi (gimple_call_arg (g, 1)); + if (!get_loop (fun, ifcvt_loop) || !get_loop (fun, orig_loop)) { if (dump_file) fprintf (dump_file, "If-converted loop vanished\n");