From patchwork Tue Oct 27 22:48:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 1389012 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=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ucw.cz Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (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 4CLRhd5wYtz9sV0 for ; Wed, 28 Oct 2020 09:49:04 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id BA80D3959E42; Tue, 27 Oct 2020 22:49:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 92AE13857C4D for ; Tue, 27 Oct 2020 22:48:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 92AE13857C4D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=hubicka@kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id B72B828291F; Tue, 27 Oct 2020 23:48:57 +0100 (CET) Date: Tue, 27 Oct 2020 23:48:57 +0100 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Avoid typeless storage in trailing wide ints Message-ID: <20201027224857.GD25210@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-15.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, 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" Hi, this patch avoid typeless storage in trailing_wide_ints. This improves TBAA disambiguation rate on cc1plus by 7%. Bootstrapped/regtested x86_64-linux, OK? * wide-int.h (trailing_wide_ints ): Turn len to array of structures so it does not imply typeless storage. (trailing_wide_ints ::operator): update (trailing_wide_ints ::operator []): Update. diff --git a/gcc/wide-int.h b/gcc/wide-int.h index 39cd5b9bd17..6eae46da12e 100644 --- a/gcc/wide-int.h +++ b/gcc/wide-int.h @@ -1387,8 +1387,10 @@ private: /* The shared maximum length of each number. */ unsigned char m_max_len; - /* The current length of each number. */ - unsigned char m_len[N]; + /* The current length of each number. + Avoid char array so the whole structure is not a typeless storage + that will, in turn, turn off TBAA on gimple, trees and RTL. */ + struct {unsigned char len;} m_len[N]; /* The variable-length part of the structure, which always contains at least one HWI. Element I starts at index I * M_MAX_LEN. */ @@ -1470,7 +1472,7 @@ template inline trailing_wide_int trailing_wide_ints ::operator [] (unsigned int index) { - return trailing_wide_int_storage (m_precision, &m_len[index], + return trailing_wide_int_storage (m_precision, &m_len[index].len, &m_val[index * m_max_len]); } @@ -1479,7 +1481,7 @@ inline typename trailing_wide_ints ::const_reference trailing_wide_ints ::operator [] (unsigned int index) const { return wi::storage_ref (&m_val[index * m_max_len], - m_len[index], m_precision); + m_len[index].len, m_precision); } /* Return how many extra bytes need to be added to the end of the structure