From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 2040A384B824; Fri, 29 Jan 2021 11:51:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2040A384B824 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 r9-9211] tree-optimization/97627 - Avoid computing niters for fake edges X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/releases/gcc-9 X-Git-Oldrev: 2ff3263feb0e3e6f1f9626ffc49412fd503f9248 X-Git-Newrev: a7e6e7a9299208e5aa3d805d502370d59f92b8b5 Message-Id: <20210129115127.2040A384B824@sourceware.org> Date: Fri, 29 Jan 2021 11:51:27 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Jan 2021 11:51:27 -0000 https://gcc.gnu.org/g:a7e6e7a9299208e5aa3d805d502370d59f92b8b5 commit r9-9211-ga7e6e7a9299208e5aa3d805d502370d59f92b8b5 Author: Richard Biener Date: Fri Jan 29 11:17:42 2021 +0100 tree-optimization/97627 - Avoid computing niters for fake edges This avoids computing niters information for fake edges. 2021-01-29 Bin Cheng Richard Biener PR tree-optimization/97627 * tree-ssa-loop-niter.c (number_of_iterations_exit_assumptions): Do not analyze fake edges. * g++.dg/pr97627.C: New testcase. (cherry picked from commit 3976b2701b826569ffcd90877d94095def507e3f) Diff: --- gcc/testsuite/g++.dg/pr97627.C | 44 ++++++++++++++++++++++++++++++++++++++++++ gcc/tree-ssa-loop-niter.c | 5 +++++ 2 files changed, 49 insertions(+) diff --git a/gcc/testsuite/g++.dg/pr97627.C b/gcc/testsuite/g++.dg/pr97627.C new file mode 100644 index 00000000000..81466dc3b81 --- /dev/null +++ b/gcc/testsuite/g++.dg/pr97627.C @@ -0,0 +1,44 @@ +/* PR tree-optimization/97627. */ +/* { dg-do run } */ + +struct S { unsigned short x, y; } m = { 1, 0 }; + +__attribute__((noipa)) void +baz (int x, int y) +{ + if (x != 0 || y != 1) + __builtin_abort (); +} + +__attribute__((noipa)) void +bar () +{ + throw 1; +} + +void +foo () +{ + while (1) + { + int a = m.x + 1; + int b = m.y + 1; + for (int c = 0; c < a; c++) + for (int d = 0; d < b; d++) + baz (d, b); + bar (); + } +} + +int +main () +{ + try + { + foo (); + } + catch (int) + { + } + return 0; +} diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 470b6a295be..200344b42dd 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2382,6 +2382,11 @@ number_of_iterations_exit_assumptions (struct loop *loop, edge exit, affine_iv iv0, iv1; bool safe; + /* The condition at a fake exit (if it exists) does not control its + execution. */ + if (exit->flags & EDGE_FAKE) + return false; + /* Nothing to analyze if the loop is known to be infinite. */ if (loop_constraint_set_p (loop, LOOP_C_INFINITE)) return false;