From patchwork Tue Jan 5 07:46:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1422374 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=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D94MD5Xbsz9sVs for ; Tue, 5 Jan 2021 18:46:48 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7302D388CC06; Tue, 5 Jan 2021 07:46:45 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [IPv6:2620:20:4000:0:a9e:1ff:fe9b:1d1]) by sourceware.org (Postfix) with ESMTP id 87398385780A for ; Tue, 5 Jan 2021 07:46:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 87398385780A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=oliva@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 3DA0F117443; Tue, 5 Jan 2021 02:46:42 -0500 (EST) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id lBWXhpZgMoba; Tue, 5 Jan 2021 02:46:42 -0500 (EST) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id D172E1174F7; Tue, 5 Jan 2021 02:46:41 -0500 (EST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 1057kZma407154 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 5 Jan 2021 04:46:36 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Subject: add alignment to enable store merging in strict-alignment targets Organization: Free thinker, does not speak for AdaCore Date: Tue, 05 Jan 2021 04:46:35 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" In g++.dg/opt/store-merging-2.C, the natural alignment of types T and S is a single byte, so we shouldn't expect store merging on strict-alignment platforms. Indeed, without something like the adjust-alignment pass to bump up the alignment of the automatic variable, as in GCC 10, the optimization does not occur. This patch adjusts the test so that the required alignment is expressly stated, and so we don't rely on its accidentally being there to get the desired optimization. Regstrapped on x86_64-linux-gnu, also tested on x-arm-wrs-vxworks7r2. Ok to install? for gcc/testsuite/ChangeLog * g++.dg/opt/store-merging-2.C: Add the required alignment. --- gcc/testsuite/g++.dg/opt/store-merging-2.C | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gcc/testsuite/g++.dg/opt/store-merging-2.C b/gcc/testsuite/g++.dg/opt/store-merging-2.C index 3c17033764b75..b1ad7018a1789 100644 --- a/gcc/testsuite/g++.dg/opt/store-merging-2.C +++ b/gcc/testsuite/g++.dg/opt/store-merging-2.C @@ -4,7 +4,9 @@ // { dg-options "-O2 -flifetime-dse=2 -fdump-tree-store-merging-details" } // { dg-final { scan-tree-dump "New sequence of 2 stores to replace old one of 3 stores" "store-merging" } } -struct T { char a[128]; }; +/* The alignment is necessary for store-merging to take place on + strict-alignment targets. */ +struct __attribute__ ((__aligned__ (4))) T { char a[128]; }; struct S { S () : a () { a.a[12] = 0; a.a[13] = 1; a.a[14] = 0; a.a[15] = 6; } T a; }; void foo (S &); void bar (void) { S s; foo (s); }