From patchwork Thu Jul 21 16:50:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Cheng X-Patchwork-Id: 651280 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 3rwKXy3S4Yz9t0V for ; Fri, 22 Jul 2016 02:50:58 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TSkY2nDz; 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:mime-version:content-type; q=dns; s=default; b=Z0CYVGys11J7Aml+iXAdxIlsmAZnF2fK6Yon/fCyudWgC4Jbza 9nG2bYaz3vDK60iVjuTBZA0jZoi6HH8wa8/M3rj1dSTkRIxNSClPGrhmPX1PQSu+ SD+Xow50NytqX+39jtFTcTzH7mr+pvyrK0znJs4JLxVx2VT1TTOkwoul8= 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=QOU+ikPf/MxJtQ9VJIAWdUUGK7U=; b=TSkY2nDzxUdSZrAekaHH hiN542rXYFmFef3F/+4El+K29ZorMEaXVUWA/8rEER8HOGLW196weWTzU5kcBHxv t2bNBhjGMS/IsoRlD10hEhUpyV/dzPsk4t5hoPMJ6vpJ5tch8EW7uPiJk527EMfo s67R52scNel7ys0Bp8uoPXs= Received: (qmail 73121 invoked by alias); 21 Jul 2016 16:50:50 -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 73108 invoked by uid 89); 21 Jul 2016 16:50:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.6 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3444, H*c:HHH X-HELO: eu-smtp-delivery-143.mimecast.com Received: from eu-smtp-delivery-143.mimecast.com (HELO eu-smtp-delivery-143.mimecast.com) (207.82.80.143) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 21 Jul 2016 16:50:39 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp0210.outbound.protection.outlook.com [213.199.154.210]) (Using TLS) by eu-smtp-1.mimecast.com with ESMTP id uk-mta-50-I5rMuwkPPnKIC4GO404Ljw-1; Thu, 21 Jul 2016 17:50:34 +0100 Received: from HE1PR0801MB1755.eurprd08.prod.outlook.com (10.168.150.10) by HE1PR0801MB1754.eurprd08.prod.outlook.com (10.168.150.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.544.10; Thu, 21 Jul 2016 16:50:33 +0000 Received: from HE1PR0801MB1755.eurprd08.prod.outlook.com ([10.168.150.10]) by HE1PR0801MB1755.eurprd08.prod.outlook.com ([10.168.150.10]) with mapi id 15.01.0539.021; Thu, 21 Jul 2016 16:50:31 +0000 From: Bin Cheng To: "gcc-patches@gcc.gnu.org" CC: nd Subject: [PATCH GCC/03]New option warning missed optimization on loops whose counter may overflow Date: Thu, 21 Jul 2016 16:50:31 +0000 Message-ID: x-ms-office365-filtering-correlation-id: b09929f1-740f-4f73-02cc-08d3b187208d x-microsoft-exchange-diagnostics: 1; HE1PR0801MB1754; 20:XhBj30FuJDLEeurPR0JHpQbNq+MA3NMDDQQEgXQQ6eGDpRrS73Ica0sJXj0S3CHXUB1er8Mt9aTfzjT0I3nm/bZHi40UayaaVMl55kZRPRcQ4uwZxKvvOPIbk14zweKoBUBe2A72PIXiNETyVerpML1QvC21dOolUp4IPsKGHKA= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1754; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(180628864354917); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(102415321)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:HE1PR0801MB1754; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0801MB1754; x-forefront-prvs: 0010D93EFE x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(199003)(377424004)(189002)(7846002)(305945005)(74316002)(3660700001)(77096005)(99936001)(7736002)(50986999)(54356999)(5003600100003)(101416001)(97736004)(2501003)(8936002)(81166006)(81156014)(33656002)(229853001)(10400500002)(7696003)(4326007)(2900100001)(86362001)(2351001)(3280700002)(105586002)(106116001)(106356001)(68736007)(5002640100001)(2906002)(87936001)(76576001)(122556002)(9686002)(450100001)(66066001)(8676002)(3846002)(110136002)(19580405001)(6116002)(19580395003)(92566002)(102836003)(586003)(189998001)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB1754; H:HE1PR0801MB1755.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jul 2016 16:50:31.2779 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1754 X-MC-Unique: I5rMuwkPPnKIC4GO404Ljw-1 X-IsSubscribed: yes Hi, This patch adds new option -Wmissed-loop-optimizations warning on loops whose counter may overflow, as well as makes -Wunsafe-loop-optimizations an alias to the new option. Bootstrap and test on x86_64 ongoing. Is it OK? Thanks, bin 2016-07-20 Bin Cheng * common.opt (Wmissed-loop-optimizations): New option. (Wunsafe-loop-optimizations): Alias to Wmissed-loop-optimizations. * doc/invoke.texi (Wmissed-loop-optimizations): Ditto. (Wunsafe-loop-optimizations): Alias to Wmissed-loop-optimizations. * tree-ssa-loop-niter.c (number_of_iterations_exit): Use option Wmissed-loop-optimizations. diff --git a/gcc/common.opt b/gcc/common.opt index 8a292ed..3d62657 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -625,7 +625,12 @@ Common Var(warn_null_dereference) Warning Warn if dereferencing a NULL pointer may lead to erroneous or undefined behavior. Wunsafe-loop-optimizations -Common Var(warn_unsafe_loop_optimizations) Warning +Common Alias(Wmissed-loop-optimizations) +Warn if the loop cannot be optimized due to nontrivial assumptions. +Same as -Wmissed-loop-optimizations. + +Wmissed-loop-optimizations +Common Var(warn_missed_loop_optimizations) Warning Warn if the loop cannot be optimized due to nontrivial assumptions. Wmissing-noreturn diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3041c18..5a2bb09 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -302,8 +302,8 @@ Objective-C and Objective-C++ Dialects}. -Wswitch -Wswitch-bool -Wswitch-default -Wswitch-enum @gol -Wswitch-unreachable -Wsync-nand @gol -Wsystem-headers -Wtautological-compare -Wtrampolines -Wtrigraphs @gol --Wtype-limits -Wundef @gol --Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations @gol +-Wtype-limits -Wundef -Wuninitialized -Wunknown-pragmas @gol +-Wmissed-loop-optimizations -Wunsafe-loop-optimizations @gol -Wunsuffixed-float-constants -Wunused -Wunused-function @gol -Wunused-label -Wunused-local-typedefs -Wunused-parameter @gol -Wno-unused-result -Wunused-value @gol -Wunused-variable @gol @@ -4990,9 +4990,14 @@ If the stack usage is (partly) dynamic and not bounded, it's: @opindex Wunsafe-loop-optimizations @opindex Wno-unsafe-loop-optimizations Warn if the loop cannot be optimized because the compiler cannot -assume anything on the bounds of the loop indices. With -@option{-funsafe-loop-optimizations} warn if the compiler makes -such assumptions. +assume anything on the bounds of the loop indices. Same as +@option{-Wmissed-loop-optimizations}. + +@item -Wmissed-loop-optimizations +@opindex Wmissed-loop-optimizations +@opindex Wno-missed-loop-optimizations +Warn if the loop cannot be optimized because the compiler cannot +assume anything on the bounds of the loop indices. @item -Wno-pedantic-ms-format @r{(MinGW targets only)} @opindex Wno-pedantic-ms-format diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 2061eafa..38b5552 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2333,7 +2333,7 @@ number_of_iterations_exit (struct loop *loop, edge exit, wording = N_("missed loop optimization, the loop counter may overflow"); warning_at ((LOCATION_LINE (loc) > 0) ? loc : input_location, - OPT_Wunsafe_loop_optimizations, "%s", gettext (wording)); + OPT_Wmissed_loop_optimizations, "%s", gettext (wording)); } return false;