From patchwork Wed Jul 27 19:38:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 653466 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3s05063Yb4z9t1x for ; Thu, 28 Jul 2016 05:39:02 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=VHtMm4YS; dkim-atps=neutral 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:content-type:mime-version; q=dns; s=default; b=R8RT4HPBzDTDyXnRa2gvYrsq1rWXqa8b0c0oPmKYuiNuFQPjOg vJ75235NtrxZF2ijORESI6hMCNhi0dPMQixeKmof9iYROVXEAzpezrIMg5TirlKg pHrGbCBq4tnTTvxqQaKOVH3mJJV4l2Pp8eVh2GeZBt9p0KiVlI2T7WOpI= 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:content-type:mime-version; s= default; bh=CGK8NvVEqw0PLgoiAWTNz26fFhU=; b=VHtMm4YSu607TXz26r35 1G79IEbLxJbdgCedQH+m112l/k4lh79UGKUS6K5n1OjgzePJdMSlTK/ar2q+cbZP xIrtCcBHka43eSoD72bKk4qIrmPpkduABduNoUTkcFUsUFt/7bZ78w9S7A5zzYZO acT2godjl2MCO8yc/A+bPLA= Received: (qmail 130885 invoked by alias); 27 Jul 2016 19:38:52 -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 130875 invoked by uid 89); 27 Jul 2016 19:38:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 spammy=sizetype, expr.c, storlayoutc, UD:expr.c X-HELO: COL004-OMC2S8.hotmail.com Received: from col004-omc2s8.hotmail.com (HELO COL004-OMC2S8.hotmail.com) (65.55.34.82) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA256 encrypted) ESMTPS; Wed, 27 Jul 2016 19:38:41 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com ([65.55.34.73]) by COL004-OMC2S8.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Wed, 27 Jul 2016 12:38:40 -0700 Received: from DB5EUR01FT022.eop-EUR01.prod.protection.outlook.com (10.152.4.52) by DB5EUR01HT129.eop-EUR01.prod.protection.outlook.com (10.152.5.195) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.5; Wed, 27 Jul 2016 19:38:38 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.4.56) by DB5EUR01FT022.mail.protection.outlook.com (10.152.4.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.549.5 via Frontend Transport; Wed, 27 Jul 2016 19:38:37 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) by AM4PR0701MB2162.eurprd07.prod.outlook.com ([10.167.132.147]) with mapi id 15.01.0549.016; Wed, 27 Jul 2016 19:38:36 +0000 From: Bernd Edlinger To: GCC Patches CC: Richard Biener , Jeff Law Subject: [PATCH] Remove BITS_PER_UNIT_LOG Date: Wed, 27 Jul 2016 19:38:36 +0000 Message-ID: authentication-results: spf=softfail (sender IP is 10.152.4.56) smtp.mailfrom=hotmail.de; suse.de; dkim=none (message not signed) header.d=none; suse.de; dmarc=none action=none header.from=hotmail.de; received-spf: SoftFail (protection.outlook.com: domain of transitioning hotmail.de discourages use of 10.152.4.56 as permitted sender) x-ms-exchange-messagesentrepresentingtype: 1 x-tmn: [UrMV8xZc0J1ZFvKBbJ1bvhNhoceu6Fzz] x-eopattributedmessage: 0 x-forefront-antispam-report: CIP:10.152.4.56; IPV:NLI; CTRY:; EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:DB5EUR01HT129; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-microsoft-exchange-diagnostics: 1; DB5EUR01HT129; 5:WszJ4d6sxD1tbvafbNj1Ojudf1YiWpV4fpKUMgKltGpo+zcSzfnpUA5arJygCAx3UXOiLr7cl92iyEHrXKUM1VvXFqn4c30asSYB8/d51u7UaVjdofPuxpm3xE+giKIsUOHjBTW8td/zg5055jN9GA==; 24:rKRORgTyq0Puh2LF/2jv8xRIrCJFZo0LH2d4NKqYDDaaOR8eTEl21qnIJdqZWHXmJDJItev25tb7hLZRdBCXQPrhEkGK0IG+4xukaI4lN64=; 7:Mox/5lIh48B8mCKqxu88jnJo5VKjNnw4vhQecJf1ZQBfAbTlIE7uh89jLs111L5MvmO8HVqLuOeU6QbG+Q9s8DlLq2iErdegzPOoXeDQkYyN4YpqaiLRpVbq3cy4tox4INDZoCn4Cb6vY9Zxo4Jrkb/2vp7fXjEUpNmtMn0DWTt9aUxYSe3JYZxDTHWQxPIIVz9UycXBFHIVnnMA7cDFaTnf6rSIqeGvX30Pm2uq839p/KcixuO087WRAktBOJvG x-ms-office365-filtering-correlation-id: 05e6c2fa-cdb8-4f7d-c65a-08d3b6559a30 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(1601124038)(1601125047); SRVR:DB5EUR01HT129; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(102415321)(82015046); SRVR:DB5EUR01HT129; BCL:0; PCL:0; RULEID:; SRVR:DB5EUR01HT129; x-forefront-prvs: 0016DEFF96 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Jul 2016 19:38:36.2953 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5EUR01HT129 Hi! I've noticed that there are two defines for log2 of BITS_PER_UNIT: BITS_PER_UNIT_LOG and LOG2_BITS_PER_UNIT. At least this wheel was apparently invented more than once :) Thus I'd say the most simple wheel will do for us as well. This patch removes BITS_PER_UNIT_LOG as this is less often used, and moves LOG2_BITS_PER_UNIT to tree.h because default.h is obviously not always included before tree.h. Bootstrap and reg-test on x86_64-pc-linux-gnu. Is it OK for trunk? Thanks Bernd. gcc: 2016-07-27 Bernd Edlinger * defaults.h (LOG2_BITS_PER_UNIT): Move from here... * tree.h (LOG2_BITS_PER_UNIT): ...to here. (BITS_PER_UNIT_LOG): Remove. (int_bit_position): Use LOG2_BITS_PER_UNIT instead of BITS_PER_UNIT_LOG. * expr.c (expand_assignment): Likewise. * stor-layout.c (initialize_sizetypes): Likewise. c-family: 2016-07-27 Bernd Edlinger * c-common.c (check_user_alignment): Use LOG2_BITS_PER_UNIT instead of BITS_PER_UNIT_LOG. Index: gcc/c-family/c-common.c =================================================================== --- gcc/c-family/c-common.c (revision 238784) +++ gcc/c-family/c-common.c (working copy) @@ -7679,7 +7679,7 @@ check_user_alignment (const_tree align, bool allow error ("requested alignment is not a positive power of 2"); return -1; } - else if (i >= HOST_BITS_PER_INT - BITS_PER_UNIT_LOG) + else if (i >= HOST_BITS_PER_INT - LOG2_BITS_PER_UNIT) { error ("requested alignment is too large"); return -1; Index: gcc/defaults.h =================================================================== --- gcc/defaults.h (revision 238784) +++ gcc/defaults.h (working copy) @@ -491,14 +491,6 @@ see the files COPYING3 and COPYING.RUNTIME respect your target, you should override these values by defining the appropriate symbols in your tm.h file. */ -#if BITS_PER_UNIT == 8 -#define LOG2_BITS_PER_UNIT 3 -#elif BITS_PER_UNIT == 16 -#define LOG2_BITS_PER_UNIT 4 -#else -#error Unknown BITS_PER_UNIT -#endif - #ifndef BITS_PER_WORD #define BITS_PER_WORD (BITS_PER_UNIT * UNITS_PER_WORD) #endif Index: gcc/expr.c =================================================================== --- gcc/expr.c (revision 238784) +++ gcc/expr.c (working copy) @@ -4990,8 +4990,7 @@ expand_assignment (tree to, tree from, bool nontem if (bitpos < 0) { gcc_assert (offset == NULL_TREE); - offset = size_int (bitpos >> (BITS_PER_UNIT == 8 - ? 3 : exact_log2 (BITS_PER_UNIT))); + offset = size_int (bitpos >> LOG2_BITS_PER_UNIT); bitpos &= BITS_PER_UNIT - 1; } Index: gcc/stor-layout.c =================================================================== --- gcc/stor-layout.c (revision 238784) +++ gcc/stor-layout.c (working copy) @@ -2572,7 +2572,7 @@ initialize_sizetypes (void) } bprecision - = MIN (precision + BITS_PER_UNIT_LOG + 1, MAX_FIXED_MODE_SIZE); + = MIN (precision + LOG2_BITS_PER_UNIT + 1, MAX_FIXED_MODE_SIZE); bprecision = GET_MODE_PRECISION (smallest_mode_for_size (bprecision, MODE_INT)); if (bprecision > HOST_BITS_PER_DOUBLE_INT) Index: gcc/tree.h =================================================================== --- gcc/tree.h (revision 238784) +++ gcc/tree.h (working copy) @@ -4235,6 +4235,8 @@ extern tree bit_position (const_tree); extern tree byte_position (const_tree); extern HOST_WIDE_INT int_byte_position (const_tree); +/* Type for sizes of data-type. */ + #define sizetype sizetype_tab[(int) stk_sizetype] #define bitsizetype sizetype_tab[(int) stk_bitsizetype] #define ssizetype sizetype_tab[(int) stk_ssizetype] @@ -4244,12 +4246,15 @@ extern HOST_WIDE_INT int_byte_position (const_tree #define bitsize_int(L) size_int_kind (L, stk_bitsizetype) #define sbitsize_int(L) size_int_kind (L, stk_sbitsizetype) -/* Type for sizes of data-type. */ +/* Log2 of BITS_PER_UNIT. */ -#define BITS_PER_UNIT_LOG \ - ((BITS_PER_UNIT > 1) + (BITS_PER_UNIT > 2) + (BITS_PER_UNIT > 4) \ - + (BITS_PER_UNIT > 8) + (BITS_PER_UNIT > 16) + (BITS_PER_UNIT > 32) \ - + (BITS_PER_UNIT > 64) + (BITS_PER_UNIT > 128) + (BITS_PER_UNIT > 256)) +#if BITS_PER_UNIT == 8 +#define LOG2_BITS_PER_UNIT 3 +#elif BITS_PER_UNIT == 16 +#define LOG2_BITS_PER_UNIT 4 +#else +#error Unknown BITS_PER_UNIT +#endif /* Concatenate two lists (chains of TREE_LIST nodes) X and Y by making the last node in X point to Y. @@ -5400,8 +5405,8 @@ extern GTY(()) struct int_n_trees_t int_n_trees[NU inline HOST_WIDE_INT int_bit_position (const_tree field) -{ - return ((wi::to_offset (DECL_FIELD_OFFSET (field)) << BITS_PER_UNIT_LOG) +{ + return ((wi::to_offset (DECL_FIELD_OFFSET (field)) << LOG2_BITS_PER_UNIT) + wi::to_offset (DECL_FIELD_BIT_OFFSET (field))).to_shwi (); }