aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2024-02-14 17:37:34 +0100
committerJan Hubicka <jh@suse.cz>2024-02-14 17:37:34 +0100
commit8d51bfe0f97a27c749c36003867901338833340a (patch)
treea39342e5231170b14a73aefe2483be6bf6de5b73 /gcc
parent16ae5efedd389e8952f35bb10665518c22a9251c (diff)
downloadgcc-8d51bfe0f97a27c749c36003867901338833340a.zip
gcc-8d51bfe0f97a27c749c36003867901338833340a.tar.gz
gcc-8d51bfe0f97a27c749c36003867901338833340a.tar.bz2
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.c-torture/compile/pr111054.c11
-rw-r--r--gcc/tree-ssa-loop-split.cc3
2 files changed, 13 insertions, 1 deletions
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 0000000..3c0d6e8
--- /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 04215fe..c0bb1b7 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)