From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9B550383543B; Mon, 12 Jul 2021 10:19:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9B550383543B 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 r12-2244] tree-optimization/101394 - fix PRE full redundancy wrt abnormals X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 123d0a597beb6d9865f808bf15b0d67f2a8fd5b2 X-Git-Newrev: 92343e0ba4d47f21ae20ffcb83d736bdbc15dae0 Message-Id: <20210712101901.9B550383543B@sourceware.org> Date: Mon, 12 Jul 2021 10:19:01 +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: Mon, 12 Jul 2021 10:19:01 -0000 https://gcc.gnu.org/g:92343e0ba4d47f21ae20ffcb83d736bdbc15dae0 commit r12-2244-g92343e0ba4d47f21ae20ffcb83d736bdbc15dae0 Author: Richard Biener Date: Mon Jul 12 10:49:03 2021 +0200 tree-optimization/101394 - fix PRE full redundancy wrt abnormals This avoids adding a copy from an abnormal picked up from PHI translation much like we'd avoid inserting the translated expression on pred edges. 2021-07-12 Richard Biener PR tree-optimization/101394 * tree-ssa-pre.c (do_pre_regular_insertion): Avoid inserting copies from abnormals for a full redundancy. * gcc.dg/torture/pr101394.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr101394.c | 18 ++++++++++++++++++ gcc/tree-ssa-pre.c | 6 +++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr101394.c b/gcc/testsuite/gcc.dg/torture/pr101394.c new file mode 100644 index 00000000000..87fbdadc152 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr101394.c @@ -0,0 +1,18 @@ +/* { dg-do compile } */ + +int a, b, c, d; +void h(); +int e() __attribute__((returns_twice)); +void f() { + int *g = (int *)(__INTPTR_TYPE__)c; + if (b) { + h(); + g--; + if (a) + if (d) + h(); + } + if (g++) + e(); + c = (__INTPTR_TYPE__)g; +} diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index d86fe26bd07..69141c2f0c9 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3412,7 +3412,11 @@ do_pre_regular_insertion (basic_block block, basic_block dom, /* If all edges produce the same value and that value is an invariant, then the PHI has the same value on all edges. Note this. */ - else if (!cant_insert && all_same) + else if (!cant_insert + && all_same + && (edoubleprime->kind != NAME + || !SSA_NAME_OCCURS_IN_ABNORMAL_PHI + (PRE_EXPR_NAME (edoubleprime)))) { gcc_assert (edoubleprime->kind == CONSTANT || edoubleprime->kind == NAME);