From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id DAE233858D33 for ; Thu, 16 Feb 2023 07:29:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DAE233858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 0DF0E200B0 for ; Thu, 16 Feb 2023 07:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1676532568; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=mKKryAytpSb0hKjsby2MgBnJPgAiVBiS7nSth+AVb84=; b=vewrOABHJyCKhMyiNVM+i6bwkenYpai01tVQBJ5q+SQwP2ZOzokr9DpUfhUQUGEMz0N5ZL WVAHNLVeIDeR2N0atohY6R1FHxuNpxG3jHpS+E6rcXZ3R49GRqvYv3RzQR7qdZL54267ZF evN/DXQtV9Eo1uTVxfbQi/NzTkoxaVg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1676532568; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=mKKryAytpSb0hKjsby2MgBnJPgAiVBiS7nSth+AVb84=; b=Y1RWfNocoms4MZgxi8JLeYEZi6Z2RtpA8eRqa6w0/ZEI1tX+rNmerLygCeTr+vzbyqpwlp 8TzN31HB/EirqlAw== Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 01D402C142 for ; Thu, 16 Feb 2023 07:29:27 +0000 (UTC) Date: Thu, 16 Feb 2023 07:29:26 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/108791 - checking ICE with sloppy ADDR_EXPR User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,MISSING_MID,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Message-ID: <20230216072926.s-eNS7LT0cpnxuNj5mfrEL2jNIihtCPFi1lCm2W6jUU@z> The following fixes a checking ICE by choosing a more appropriate type for an ADDR_EXPR built by forwprop. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. 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. --- gcc/testsuite/gcc.dg/torture/pr108791.c | 9 +++++++++ gcc/tree-ssa-forwprop.cc | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr108791.c 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))); -- 2.35.3