From patchwork Tue Apr 25 06:25:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 87253 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3204496vqo; Mon, 24 Apr 2023 23:26:31 -0700 (PDT) X-Google-Smtp-Source: AKy350YKU6dIQkJFcO/xsfCwApiVUI920wcgKp0uJkkysPgrnY8l4ICl+hbM91aqcJWf3zioMqCG X-Received: by 2002:a05:6402:1a42:b0:506:8838:45cc with SMTP id bf2-20020a0564021a4200b00506883845ccmr12385582edb.6.1682403991260; Mon, 24 Apr 2023 23:26:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682403991; cv=none; d=google.com; s=arc-20160816; b=zYL2bH6C2YSXA1C+VN8fTEApDQo8JyyaLtDwxE1RMYezlpv1ADh/gQaO7iI56qJ1Aa fxDhJ22HaoecRPkx8iZdj/8kVO7A9i/spAwUN4c9W2rPHuBTceU7yypEe+eKxykxM99R VPHfCiJ2DkmggdnthhhD1G+8+3Z4k1WD/S1z1MhkCIa3DryBhRLrDltQbYPVmKB8UCco yBSW2eokjNWt9tABzf+BUhuAU1PVyx7hM1Q61vCWrZr2vd7n2aV3vHo/1pgaJfjn27Jq CLrx9QIZ2yyCkURxWT607kBKI2dKp0Vx/L/VayQaCGGR5UeWUrhLFOsjOKO873R0Uxxo pScw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:cc:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=qQjj1/IsqJH4gm8xXms6WaKjefGrM1PGYMmmX5b6IQ0=; b=X1Jr2KZ+yvUV04fUslsYfVw2bQvSIHJNL9vb8EYrK4708JLKvB38BhSGh1FoCPLpIu VB26yAmR3A2T4fMLgIkLl0W1pluTAdkzHBr+NCcmKoz+C73R7sYkFcFaR0O9LSoLHjgD e0SjR4Zx5m7sbnbo5dtAuiuaTRVspaOrsT4i2YshuOz/fAPEmdF6kQ4KIXD/PqiMnEWp gN1VeTGwOj8nInCER2PH7RrI6gxXEYloll1ao0CqioRakfMGefKGJrlyjb2bQi8uBCy8 hWL+xSxZ7p5XgqHQfQLnswUTug+f45vE9Kie1DyRo7VxDj22B9iw1sfBBW8UL69auFO2 bsXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YQDcQp0w; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id u12-20020aa7d88c000000b00506bd1b984dsi9524122edq.89.2023.04.24.23.26.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Apr 2023 23:26:31 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=YQDcQp0w; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2DEBA3858C30 for ; Tue, 25 Apr 2023 06:26:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2DEBA3858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1682403990; bh=qQjj1/IsqJH4gm8xXms6WaKjefGrM1PGYMmmX5b6IQ0=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=YQDcQp0wocVzVhi+NoEAwcIis9+X8AnZc76Y/epi/mEjWoLLnlz3PQ6kRHld6Ca0G C7ADtR3XzH/Rzk0pwT05cYBk/c/RyBjntfOOOFJv3BcA3+MHFb59SSKSFoSj7osBB1 kDfcbQFeNofTBfGfma+nTG9tNvr0BKevxUFSvxWM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id 772FF3858D1E for ; Tue, 25 Apr 2023 06:25:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 772FF3858D1E Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id AAA0A1FDA5; Tue, 25 Apr 2023 06:25:43 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 851AF13466; Tue, 25 Apr 2023 06:25:43 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id lt1AH2dyR2SdGgAAMHmgww (envelope-from ); Tue, 25 Apr 2023 06:25:43 +0000 Date: Tue, 25 Apr 2023 08:25:43 +0200 (CEST) To: gcc-patches@gcc.gnu.org cc: Jan Hubicka Subject: [PATCH] rtl-optimization/109585 - alias analysis typo MIME-Version: 1.0 Message-Id: <20230425062543.851AF13466@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764128447740084812?= X-GMAIL-MSGID: =?utf-8?q?1764128447740084812?= When r10-514-gc6b84edb6110dd2b4fb improved access path analysis it introduced a typo that triggers when there's an access to a trailing array in the first access path leading to false disambiguation. Bootstrapped and tested on x86_64-unknown-linux-gnu. Honza, does this look OK? Thanks, Richard. PR rtl-optimization/109585 * tree-ssa-alias.cc (aliasing_component_refs_p): Fix typo. * gcc.dg/torture/pr109585.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr109585.c | 33 +++++++++++++++++++++++++ gcc/tree-ssa-alias.cc | 2 +- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr109585.c diff --git a/gcc/testsuite/gcc.dg/torture/pr109585.c b/gcc/testsuite/gcc.dg/torture/pr109585.c new file mode 100644 index 00000000000..f92de7c1f2e --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr109585.c @@ -0,0 +1,33 @@ +/* { dg-do run } */ + +#include + +struct P { + long v; + struct P *n; +}; + +struct F { + long x; + struct P fam[]; +}; + +int __attribute__((noipa)) +f(struct F *f, int i) +{ + struct P *p = f->fam; + asm("" : "+r"(f): "r"(p)); + p->v = 0; + p->n = 0; + return f->fam->n != 0; +} + +int +main() +{ + struct F *m = malloc (sizeof (long) + 2 * sizeof (struct P)); + m->fam[0].n = &m->fam[1]; + if (f (m, 0)) + abort (); + return 0; +} diff --git a/gcc/tree-ssa-alias.cc b/gcc/tree-ssa-alias.cc index 81bc51ed4ad..8a1ec9091fa 100644 --- a/gcc/tree-ssa-alias.cc +++ b/gcc/tree-ssa-alias.cc @@ -1330,7 +1330,7 @@ aliasing_component_refs_p (tree ref1, /* If we didn't find a common base, try the other way around. */ if (cmp_outer <= 0 || (end_struct_ref1 - && compare_type_sizes (TREE_TYPE (end_struct_ref1), type1) <= 0)) + && compare_type_sizes (TREE_TYPE (end_struct_ref1), type2) <= 0)) { int res = aliasing_component_refs_walk (ref2, type2, base2, offset2, max_size2,