From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 9D8E23858C60; Thu, 16 Feb 2023 07:30:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9D8E23858C60 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1676532656; bh=AoLTzAENa7WDhXTkPudfxNNn5vOJwquo0+EXXpXMMLc=; h=From:To:Subject:Date:From; b=vdLFxycwShCyI42z1AOUaeKmnq85xppWx489J/AUds/8xDrVN8zI6GTGwr4uyWpTo Beod+KMlMvNDn1IUJmHB0kezuwhuk3GjZtqxisIOpXN0uA9+HueP7+WZsoBJydZb6F TVJKGcqo/aG3Vmw1DrWje4w6Av4X25ej9ZtfKv3I= 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 r13-6073] tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 384dedaf65db115e9795438d787bc8bd84bb6777 X-Git-Newrev: 441c466fd4d8b9afd99f585f7c4bfade911c4652 Message-Id: <20230216073051.9D8E23858C60@sourceware.org> Date: Thu, 16 Feb 2023 07:30:51 +0000 (GMT) List-Id: https://gcc.gnu.org/g:441c466fd4d8b9afd99f585f7c4bfade911c4652 commit r13-6073-g441c466fd4d8b9afd99f585f7c4bfade911c4652 Author: Richard Biener Date: Wed Feb 15 14:00:21 2023 +0100 tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR The following fixes a checking ICE by choosing a more appropriate type for an ADDR_EXPR built by forwprop. PR tree-optimization/108791 * tree-ssa-forwprop.cc (optimize_vector_load): Build the ADDR_EXPR of a TARGET_MEM_REF using a more meaningful type. * gcc.dg/torture/pr108791.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/torture/pr108791.c | 9 +++++++++ gcc/tree-ssa-forwprop.cc | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/torture/pr108791.c b/gcc/testsuite/gcc.dg/torture/pr108791.c new file mode 100644 index 00000000000..c1c1cb22aad --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr108791.c @@ -0,0 +1,9 @@ +/* { dg-do compile } */ + +int f (int *a(), int *b, int *c, int *d) +{ + int s = 0; + for (int *i = (int *)a; i < b; ++i, ++c) + s += *c * d[*i]; + return s; +} diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc index 0841a739fe1..03fe0a3f6df 100644 --- a/gcc/tree-ssa-forwprop.cc +++ b/gcc/tree-ssa-forwprop.cc @@ -3299,7 +3299,8 @@ optimize_vector_load (gimple_stmt_iterator *gsi) { if (TREE_CODE (TREE_OPERAND (load_rhs, 0)) == ADDR_EXPR) mark_addressable (TREE_OPERAND (TREE_OPERAND (load_rhs, 0), 0)); - tree tem = make_ssa_name (TREE_TYPE (TREE_OPERAND (load_rhs, 0))); + tree ptrtype = build_pointer_type (TREE_TYPE (load_rhs)); + tree tem = make_ssa_name (ptrtype); gimple *new_stmt = gimple_build_assign (tem, build1 (ADDR_EXPR, TREE_TYPE (tem), unshare_expr (load_rhs)));