From patchwork Mon Nov 7 15:15:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernd Edlinger X-Patchwork-Id: 691943 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 3tCGHP4DZYz9t0t for ; Tue, 8 Nov 2016 02:16:16 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="O3g61RN1"; 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=Gp1lZ84ALIivt6+ExAqKDzmFCCTV8qZ7iLKQcKgGo7E9F+FXin 5FJC9n3XWxALaq7+KFgF251l6f2ViNzuEUIbOivgFGIZS2+QkBOftTU4HSHfNmtD qR4OBPJoBZmpO9cYwZJHWrCZYu1JPj3tRlNLl2VYjn/Sloet9gHvTTHKg= 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=/SNu4jr8I7lX3nDcE40JT8jHcKo=; b=O3g61RN1jA4hzWYyVGFT klIwO7xyWmBTMKzVzbRRhNJAjt+lNyxe6C7IWP6H9/3R6nmYlyljabt+7lQtxiYN PBB91b88XvgaOf+2EhUJNM7NtBhtmJ+LX6KhgRX0di8x+cLEOVXqO7E2Wlnss3YD Tj4HJ69pMgxpMo1L+XHv1+U= Received: (qmail 10674 invoked by alias); 7 Nov 2016 15:16:05 -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 10590 invoked by uid 89); 7 Nov 2016 15:16:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=reg-tested, cross-compiler, crosscompiler, sk:HOST_BI X-HELO: COL004-OMC3S12.hotmail.com Received: from col004-omc3s12.hotmail.com (HELO COL004-OMC3S12.hotmail.com) (65.55.34.150) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Nov 2016 15:15:54 +0000 Received: from EUR03-DB5-obe.outbound.protection.outlook.com ([65.55.34.136]) by COL004-OMC3S12.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Mon, 7 Nov 2016 07:15:52 -0800 Received: from VE1EUR03FT017.eop-EUR03.prod.protection.outlook.com (10.152.18.51) by VE1EUR03HT111.eop-EUR03.prod.protection.outlook.com (10.152.19.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.3; Mon, 7 Nov 2016 15:15:43 +0000 Received: from AM4PR0701MB2162.eurprd07.prod.outlook.com (10.152.18.57) by VE1EUR03FT017.mail.protection.outlook.com (10.152.18.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.707.3 via Frontend Transport; Mon, 7 Nov 2016 15:15:42 +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.0721.004; Mon, 7 Nov 2016 15:15:42 +0000 From: Bernd Edlinger To: Jeff Law CC: "gcc-patches@gcc.gnu.org" Subject: Re: [RFA] Fix various PPC build failures due to int-in-boolean-context code Date: Mon, 7 Nov 2016 15:15:42 +0000 Message-ID: authentication-results: redhat.com; dkim=none (message not signed) header.d=none; redhat.com; dmarc=none action=none header.from=hotmail.de; x-incomingtopheadermarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:2267; Count:34 x-ms-exchange-messagesentrepresentingtype: 1 x-incomingheadercount: 34 x-eopattributedmessage: 0 x-microsoft-exchange-diagnostics: 1; VE1EUR03HT111; 7:/0hOI59ImwN6W9Wzag20j6f7AoUhLSKoRnnGypiWhx/Qk87TEOwlVx0B0/F2eIAFXp7+Xujfqw26QiwFEekJJXC/HWhIGtnxq+99Y9A6++F6ZsmCCQhka2DyP8BIuja7aLWI/f7xnJHJp0ZGh1fanoxEOz+czDcupzf2ummmQSZKyC30S6N1Nn9NiCbM51Ab4cSykKZfLlzr8iyI3BzRHYHs462B1NBnVE4i2BQdvWV3ZxyqlKcjLtS5zf5YgnX2rP4V3gr4veYLehPJllr6jI1kNYZi/Krj20ubkxHK4GkYjSlsyDDiGIuq5y3B44kJdA96r2LmYmzLIcfAbV4XI/vzjex/rgzuWVmPXVvJxUE= x-forefront-antispam-report: EFV:NLI; SFV:NSPM; SFS:(10019020)(98900003); DIR:OUT; SFP:1102; SCL:1; SRVR:VE1EUR03HT111; H:AM4PR0701MB2162.eurprd07.prod.outlook.com; FPR:; SPF:None; LANG:en; x-ms-office365-filtering-correlation-id: f851f1cb-b280-45a9-4e69-08d40720eff6 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:VE1EUR03HT111; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(432015012)(102415335)(82015046); SRVR:VE1EUR03HT111; BCL:0; PCL:0; RULEID:; SRVR:VE1EUR03HT111; x-forefront-prvs: 0119DC3B5E spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Nov 2016 15:15:42.4957 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT111 On Fri, Oct 28, 2016 at 09:12:29AM -0600, Jeff Law wrote: > > The PPC port is stumbling over the new integer in boolean context warnings. > > In particular this code from rs6000_option_override_internal is > problematical: > > HOST_WIDE_INT flags = ((TARGET_DEFAULT) ? TARGET_DEFAULT > : > processor_target_table[cpu_index].target_enable); > > The compiler is flagging the (TARGET_DEFAULT) condition. That's > supposed to to be a boolean. > > After all the macro expansions are done it ultimately looks something > like this: > > long flags = (((1L << 7)) ? (1L << 7) > : processor_target_table[cpu_index].target_enable); > > Note the (1L << 7) used as the condition for the ternary. That's what > has the int-in-boolean-context warning tripping. It's a false positive > IMHO. Hmm... From the warning's perspective it would look far less suspicious, if we make this an unsigned shift op. I looked at options.h and I think we could also use one bit more if the shift was unsigned. Furthermore there are macros TARGET_..._P which do not put brackets around the macro parameter. So how about this? Cross-compiler for powerpc-eabi builds without warning. Bootstrapped and reg-tested on x86_64-pc-linux-gnu. Is it OK for trunk? Bernd. 2016-11-07 Bernd Edlinger * opth-gen.awk: Use unsigned shifts for bit masks. Allow all bits to be used. Add brackets around macro argument. Index: gcc/opth-gen.awk =================================================================== --- gcc/opth-gen.awk (revision 241884) +++ gcc/opth-gen.awk (working copy) @@ -350,11 +350,11 @@ for (i = 0; i < n_opts; i++) { mask_bits[name] = 1 vname = var_name(flags[i]) mask = "MASK_" - mask_1 = "1" + mask_1 = "1U" if (vname != "") { mask = "OPTION_MASK_" if (host_wide_int[vname] == "yes") - mask_1 = "HOST_WIDE_INT_1" + mask_1 = "HOST_WIDE_INT_1U" } else extra_mask_bits[name] = 1 print "#define " mask name " (" mask_1 " << " masknum[vname]++ ")" @@ -362,16 +362,16 @@ for (i = 0; i < n_opts; i++) { } for (i = 0; i < n_extra_masks; i++) { if (extra_mask_bits[extra_masks[i]] == 0) - print "#define MASK_" extra_masks[i] " (1 << " masknum[""]++ ")" + print "#define MASK_" extra_masks[i] " (1U << " masknum[""]++ ")" } for (var in masknum) { if (var != "" && host_wide_int[var] == "yes") { - print" #if defined(HOST_BITS_PER_WIDE_INT) && " masknum[var] " >= HOST_BITS_PER_WIDE_INT" + print "#if defined(HOST_BITS_PER_WIDE_INT) && " masknum[var] " > HOST_BITS_PER_WIDE_INT" print "#error too many masks for " var print "#endif" } - else if (masknum[var] > 31) { + else if (masknum[var] > 32) { if (var == "") print "#error too many target masks" else @@ -401,7 +401,7 @@ for (i = 0; i < n_opts; i++) { print "#define TARGET_" name \ " ((" vname " & " mask name ") != 0)" print "#define TARGET_" name "_P(" vname ")" \ - " ((" vname " & " mask name ") != 0)" + " (((" vname ") & " mask name ") != 0)" } } for (i = 0; i < n_extra_masks; i++) {