From patchwork Fri Feb 21 11:53:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 1242054 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-519892-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha1 header.s=default header.b=solF+cHX; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48P8xH1YmBz9sRk for ; Fri, 21 Feb 2020 22:53:38 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=hopAPFTXkSraJ2RIco/rTe048MCKmthKsenxruOKXaxl2PRxln aYFkdLZuXq8AJyZJ+eFVxWH9Yyzn261UXSeR5+NjhJWPOcevs3aoctdgsublqY9m XpYafWrJZhuRRslUykzJ8zw8Klfjzi5i4MolBP/Jv5FXRmE7uG9JcCuss= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=vy4yMA/1lsFN9YT2FYllNP0Pm5o=; b=solF+cHXq0T4Gy63Kz+a UkXoLLZjOGMnOqNRAzn4Ddyz8EQ99mqz7OmXCT83HmYX5NEVjEeD+Q1VWO6nVawO 4d4nyqUIfyS2+kJuYsSHj6TdKpKu6J1OPr4v/4f2qudZV7M/QL4KBdtVF9zCPnDj w02lbSBcX7Rl64xJoGL/KuI= Received: (qmail 32989 invoked by alias); 21 Feb 2020 11:53:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 32981 invoked by uid 89); 21 Feb 2020 11:53:29 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:verify_, m_fn4, *static_cast, *operator X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Feb 2020 11:53:28 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B439BAFB1 for ; Fri, 21 Feb 2020 11:53:25 +0000 (UTC) From: Martin Jambor To: GCC Patches Cc: Richard Biener Subject: [PATCH] sra: Only verify sizes of scalar accesses (PR 93845) User-Agent: Notmuch/0.29.3 (https://notmuchmail.org) Emacs/26.3 (x86_64-suse-linux-gnu) Date: Fri, 21 Feb 2020 12:53:25 +0100 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi, the testcase is another example - in addition to recent PR 93516 - where the SRA access verifier is confused by the fact that get_ref_base_extent can return different sizes for the same type, depending whether they are COMPONENT_REF or not. In the previous bug I decided to keep the verifier check for aggregate type even though it is not really important and instead avoid easily detectable type-within-the-same-type situation. This testcase is however a result of a fairly random looking type cast and so cannot be handled in the same way. Because the check is not really important for aggregates, this patch simply disables it for non-register types. Bootstrapped and tested on x86_64-linux. OK for trunk? Thanks, Martin 2020-02-20 Martin Jambor PR tree-optimization/93845 * tree-sra.c (verify_sra_access_forest): Only test access size of scalar types. testsuite/ * g++.dg/tree-ssa/pr93845.C: New test. --- gcc/ChangeLog | 6 +++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/tree-ssa/pr93845.C | 30 +++++++++++++++++++++++++ gcc/tree-sra.c | 3 ++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/tree-ssa/pr93845.C diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr93845.C b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C new file mode 100644 index 00000000000..72e473fffcd --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr93845.C @@ -0,0 +1,30 @@ +/* { dg-do compile } */ +/* { dg-options "-O1" } */ + +struct g; +struct h { + g *operator->(); +}; +class i { + void *a; + int b; + +public: + template f j() { return *static_cast(this); } +}; +struct k : i {}; +struct l : k {}; +struct m { + i n(); + i o(l, l, int); +}; +struct g { + void m_fn4(k); +}; +h a; +i b; +i m::n() { + l c, d, e = o(d, c, 0).j(); + a->m_fn4(e); + return b; +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index 0cfac0a8192..1439f11f15a 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -2339,7 +2339,8 @@ verify_sra_access_forest (struct access *root) gcc_assert (offset == access->offset); gcc_assert (access->grp_unscalarizable_region || size == max_size); - gcc_assert (max_size == access->size); + gcc_assert (!is_gimple_reg_type (access->type) + || max_size == access->size); gcc_assert (reverse == access->reverse); if (access->first_child)