From: Richard Biener Date: Mon, 12 Oct 2020 06:51:05 +0000 (+0200) Subject: tree-optimization/97357 - avoid abnormals in loop splitting conditions X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5b2cc633794f6e1f882d46bdefe267401d33285e;p=gcc.git tree-optimization/97357 - avoid abnormals in loop splitting conditions This avoids abnormals in another place. 2020-10-12 Richard Biener PR tree-optimization/97357 * tree-ssa-loop-split.c (ssa_semi_invariant_p): Abnormal SSA names are not semi invariant. * gcc.dg/pr97357.c: New testcase. --- diff --git a/gcc/testsuite/gcc.dg/pr97357.c b/gcc/testsuite/gcc.dg/pr97357.c new file mode 100644 index 00000000000..2b32d13a43f --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr97357.c @@ -0,0 +1,39 @@ +/* { dg-do compile } */ +/* { dg-options "-O3" } */ +/* { dg-require-effective-target indirect_jumps } */ + +#include +#include + +void * my_malloc (size_t size); + +typedef struct glk { + struct glk *nxt; +} glk; + +typedef struct Lock +{ + glk ByteLock; +} Lock; + +static Lock *l, *lk; + +void bytelocks(glk *rethead, jmp_buf jb) +{ + glk *cur, *cur_lk; + + if (( _setjmp (jb)) == 0) + for (cur = &l->ByteLock; cur != ((glk *)0) ; cur = (cur)->nxt) + for (cur_lk = &lk->ByteLock; cur_lk != ((glk *)0); cur_lk = cur_lk->nxt) + { + glk *retrng; + + if(!rethead) + rethead = (glk *) my_malloc (sizeof(glk)); + retrng = (glk *) my_malloc (sizeof(glk)); + + retrng->nxt = rethead; + } + + return; +} diff --git a/gcc/tree-ssa-loop-split.c b/gcc/tree-ssa-loop-split.c index 1eb6be5ddb2..46ee7c0fc14 100644 --- a/gcc/tree-ssa-loop-split.c +++ b/gcc/tree-ssa-loop-split.c @@ -977,6 +977,9 @@ ssa_semi_invariant_p (struct loop *loop, tree name, if (!def_bb || !flow_bb_inside_loop_p (loop, def_bb)) return true; + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (name)) + return false; + return stmt_semi_invariant_p_1 (loop, def, skip_head, stmt_stat); }