From patchwork Mon Oct 16 11:02:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 153329 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2908:b0:403:3b70:6f57 with SMTP id ib8csp3376045vqb; Mon, 16 Oct 2023 04:02:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIawBd0/GgcnozO2hj/C2SAcZClzYabOqyqFuL0zWt+ksLCGlcxOmXSlZp1izE/AIMI21r X-Received: by 2002:a05:6214:5f0c:b0:66c:eef9:4154 with SMTP id lx12-20020a0562145f0c00b0066ceef94154mr10318152qvb.23.1697454177083; Mon, 16 Oct 2023 04:02:57 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697454177; cv=pass; d=google.com; s=arc-20160816; b=fxPZuWjcEFWuQC9dwZmUKIcgF3hyEc6Mqjulgvqu6yAlxBI6uWSqFJ/OkocLNMmi6A wZGSATydtgfLpxxD+50q3EYseFFAZj7gUd9fN0djzAMBr3XoPA/Y2kjYt5yqe/ARt3XB BtzopwbUyjcYe7lVIgGzxAzkaVtt1UE1Wb3FjXhvzYsDk5VEuT4x00ojS/ywm6m5TnmM 2HdAPaISHDFV75+KFH+eRiLnK4HDgL1UD5ccfjwDFtMEEIVwEuzUZpTpCLBk9P7K30Jm dRyR52NVKDAi3RpHUhBJYAzt12FlqimmNdQ+C0rI27F74OoI62lcqnW+VjpoUObuVnJb Xeiw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :user-agent:subject:cc:to:from:date:arc-filter:dmarc-filter :delivered-to; bh=hgtwtsB+CGoxVZkofjz9u8Hb2xwSEiLpCFvYPzxJz6c=; fh=0mDrz+Jl7LRzQ2YVjufhJ2sJtYrZQqZiRW11y9I7Aso=; b=M+WUFtcqMASSpa5SO7cOSwsky6t+PNrzfRWl1HOp5s/s0xESSCBqbxFNrDw6B8YiP+ FO/QPXPE+SzcIvk97tL/y57X7CS+l5DJYrsnaw7MTKVUf8GbmC0RnPezhLtQTM09nKnT W2LQkCSMPH/G5KbE9To1UgiCZJmmWyWIaVavUf0SnrRS+Mku0FXYCji46Em6O2IwhyIg O77fxKQ6PK4ilJtlx6TyTWxTpFzCuV1ze+owJdiL7hpS1Y2Dm3/qZFOMUuGyl+6McPrM Vdo+L3hemr/6Mj4YYhqzWB9UkIJ9nOuIWYckuQGc7HePnCDq+Pw3wb5/s767uRa9w+WS yzxw== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id ez3-20020ad45903000000b0063d42d0a6acsi5104239qvb.517.2023.10.16.04.02.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 04:02:57 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D4FF03858422 for ; Mon, 16 Oct 2023 11:02:56 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E83B83858C66 for ; Mon, 16 Oct 2023 11:02:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E83B83858C66 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E83B83858C66 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.220.28 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697454154; cv=none; b=XDiL4CLo9Ins5XlakRZ54D/aWrPkTR1VuclfWuQ9Xwa9LAEpxxGQSCP28nnzvQF04natrcNq2LXlzjo1ax8EUqZAojXFuUI97ZaQtDPKj7Jjxr/4oosS623c58MBOR0+kjd7UMfnTGNTl+qlrqsK0B8J7f9XsWHpSMxJeFVI99E= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697454154; c=relaxed/simple; bh=jJTQHfAu0rPbxDRNugFBrC8KnrBTzErwJW6cZGsU/EM=; h=Date:From:To:Subject:MIME-Version; b=KeJM3Sqq6k3pfqlEKjpklcL1aAqM5RRahVeQFiQuKrxKoTFo3HeW0KUEULPyAyFzwKKtBqlYyF+L877Y3EoIIEouNWUOBWl1dul9z3LvrW+XT7I1+otCXdmPS+f+LRTabEhaYHNkC2TQG64HDd77NtZsCWIdNg0WVyko7l0uY5E= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id D7CA92185C for ; Mon, 16 Oct 2023 11:02:29 +0000 (UTC) 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 9ACCB2D13D; Mon, 16 Oct 2023 11:02:29 +0000 (UTC) Date: Mon, 16 Oct 2023 11:02:29 +0000 (UTC) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: Martin Jambor Subject: [PATCH] tree-optimization/111807 - ICE in verify_sra_access_forest User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spamd-Bar: +++++ Authentication-Results: smtp-out1.suse.de; dkim=none; dmarc=none; spf=softfail (smtp-out1.suse.de: 149.44.160.134 is neither permitted nor denied by domain of rguenther@suse.de) smtp.mailfrom=rguenther@suse.de X-Rspamd-Server: rspamd2 X-Spamd-Result: default: False [5.99 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; RWL_MAILSPIKE_GOOD(0.00)[149.44.160.134:from]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.20)[suse.de]; R_SPF_SOFTFAIL(0.60)[~all:c]; MISSING_MID(2.50)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; MX_GOOD(-0.01)[]; RCPT_COUNT_TWO(0.00)[2]; VIOLATED_DIRECT_SPF(3.50)[]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_SPAM_LONG(3.00)[1.000]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.20)[]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; BAYES_HAM(-3.00)[100.00%] X-Spam-Score: 5.99 X-Rspamd-Queue-Id: D7CA92185C X-Spam-Status: No, score=-10.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20231016110256.D4FF03858422@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1779909710862693783 X-GMAIL-MSGID: 1779909710862693783 The following addresses build_reconstructed_reference failing to build references with a different offset than the models and thus the caller conditional being off. This manifests when attempting to build a ref with offset 160 from the model BIT_FIELD_REF onto the same base l_4827 but the models offset being 288. This cannot work for any kind of ref I can think of, not just with BIT_FIELD_REFs. Bootstrapped and tested on x86_64-unknown-linux-gnu, will push later. Martin - do you remember which case was supposed to be allowed with offset < model->offset? Thanks, Richard. PR tree-optimization/111807 * tree-sra.cc (build_ref_for_model): Only call build_reconstructed_reference when the offsets are the same. * gcc.dg/torture/pr111807.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr111807.c | 12 ++++++++++++ gcc/tree-sra.cc | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr111807.c diff --git a/gcc/testsuite/gcc.dg/torture/pr111807.c b/gcc/testsuite/gcc.dg/torture/pr111807.c new file mode 100644 index 00000000000..09fbdcfb667 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr111807.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ + +static struct A { + int x : 4; +} a; +static int b; +int main() +{ + struct A t[2]; + t[0] = b ? t[1] : a; + return (b ? t[1].x : 0) && 1; +} diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc index 24d0c20da6a..f8dff8b27d7 100644 --- a/gcc/tree-sra.cc +++ b/gcc/tree-sra.cc @@ -1751,7 +1751,7 @@ build_ref_for_model (location_t loc, tree base, HOST_WIDE_INT offset, && !TREE_THIS_VOLATILE (base) && (TYPE_ADDR_SPACE (TREE_TYPE (base)) == TYPE_ADDR_SPACE (TREE_TYPE (model->expr))) - && offset <= model->offset + && offset == model->offset /* build_reconstructed_reference can still fail if we have already massaged BASE because of another type incompatibility. */ && (res = build_reconstructed_reference (loc, base, model)))