From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1075) id B3858385E45F; Wed, 14 Feb 2024 16:37:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B3858385E45F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1707928675; bh=e1WqGAkARSTa4F0oGGVqQQ8uxUCL3ffFqinSdZdkhs8=; h=From:To:Subject:Date:From; b=cGeqCXv+6GCgOPvhBXxnCsFv8juVB47bJKVHqeqxOoLLiwNrO4KBL3wrwE2eEmMUk NRpUfObju3xUo+2Jkmsi/kqtKUIFw57Fm/ZBsxoEqqx9os938x4rP3htmWiTFqgUTE PR1kyu0gQdQh0zHFyaM8IMat4OwH19OpOVhFJXyA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jan Hubicka To: gcc-cvs@gcc.gnu.org Subject: [gcc r14-8985] Fix ICE in loop splitting with -fno-guess-branch-probability X-Act-Checkin: gcc X-Git-Author: Jan Hubicka X-Git-Refname: refs/heads/master X-Git-Oldrev: 16ae5efedd389e8952f35bb10665518c22a9251c X-Git-Newrev: 8d51bfe0f97a27c749c36003867901338833340a Message-Id: <20240214163755.B3858385E45F@sourceware.org> Date: Wed, 14 Feb 2024 16:37:55 +0000 (GMT) List-Id: https://gcc.gnu.org/g:8d51bfe0f97a27c749c36003867901338833340a commit r14-8985-g8d51bfe0f97a27c749c36003867901338833340a Author: Jan Hubicka Date: Wed Feb 14 17:37:34 2024 +0100 Fix ICE in loop splitting with -fno-guess-branch-probability PR tree-optimization/111054 gcc/ChangeLog: * tree-ssa-loop-split.cc (split_loop): Check for profile being present. gcc/testsuite/ChangeLog: * gcc.c-torture/compile/pr111054.c: New test. Diff: --- gcc/testsuite/gcc.c-torture/compile/pr111054.c | 11 +++++++++++ gcc/tree-ssa-loop-split.cc | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.c-torture/compile/pr111054.c b/gcc/testsuite/gcc.c-torture/compile/pr111054.c new file mode 100644 index 000000000000..3c0d6e816b97 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr111054.c @@ -0,0 +1,11 @@ +/* { dg-additional-options "-fno-guess-branch-probability" } */ +void *p, *q; +int i, j; + +void +foo (void) +{ + for (i = 0; i < 20; i++) + if (i < j) + p = q; +} diff --git a/gcc/tree-ssa-loop-split.cc b/gcc/tree-ssa-loop-split.cc index 04215fe7937e..c0bb1b71d17c 100644 --- a/gcc/tree-ssa-loop-split.cc +++ b/gcc/tree-ssa-loop-split.cc @@ -712,7 +712,8 @@ split_loop (class loop *loop1) ? true_edge->probability.to_sreal () : (sreal)1; sreal scale2 = false_edge->probability.reliable_p () ? false_edge->probability.to_sreal () : (sreal)1; - sreal div1 = loop1_prob.to_sreal (); + sreal div1 = loop1_prob.initialized_p () + ? loop1_prob.to_sreal () : (sreal)1/(sreal)2; /* +1 to get header interations rather than latch iterations and then -1 to convert back. */ if (div1 != 0)