From patchwork Tue Jul 18 09:13:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bin.Cheng" X-Patchwork-Id: 790032 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-458392-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="bbC+hmA+"; dkim-atps=neutral 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 3xBZG95PH9z9s7C for ; Tue, 18 Jul 2017 19:13:36 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; q=dns; s=default; b=wP56ytxodXzF1YS kR+VllHs2E65TfflsM/fJ3frkJBgfEQsdKxuynZfOUqLNK+nqvxIK4i41wH8mDMs F+6cllShBaYtMILhGNiqSqXJnVgD6cYmKpjLfoinbVf22hYlfhRmYOYch9yggJ9n ZAQLu4fhBeaLzXkKcZf0jPRPPz2I= 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 :mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; s=default; bh=u6eM8c+GkcDGZVLkyoSLy dXjqKE=; b=bbC+hmA+ARVxPJipvroILV4QhIGZJcXNbi6AVBRHVEJ1rvKKuMDYT qDhMo99+uoS3jQnCy9UfrrNe0sV5jrILaHH8R+5fLmAi2lJRGjlupCI4ASRM/B5X LTYOthnna8tGyBHTrYbSdD0jyeQOXVqgJJHJPMei9vEat20J2cUL4Y= Received: (qmail 33367 invoked by alias); 18 Jul 2017 09:13:29 -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 33346 invoked by uid 89); 18 Jul 2017 09:13:27 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-ua0-f181.google.com Received: from mail-ua0-f181.google.com (HELO mail-ua0-f181.google.com) (209.85.217.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 18 Jul 2017 09:13:26 +0000 Received: by mail-ua0-f181.google.com with SMTP id 64so16217098uae.2 for ; Tue, 18 Jul 2017 02:13:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oFjTiDd13AivCH/Cb+X6gbVZFhFL84x4lB86+J8mwHY=; b=pZ8sU3NiiHiNeCvQfF9uSeUhxVZpWptr9d2dHlq4ttrtm6Je61V/fh3FRRSTpMmxR2 PbzVIPoa4fAI/81zYukdP4TL9CbKe0EtI2PLc/6hiUlq+35h8d/RT4qSWgVjX5iXYxFd rPX1GC5Oa6klAy3F7EwMytioHAzUO+KPmJH8ElshUpufj5b9nfMgkMRdQLfBjbxxFFs5 ctmJCiMFADLN9IhMlg+39CChWFFfSYky5zW8QpHWgaGPELWJ3s77+R1qBQ+/f9Z2VGLX Gvm4qbwbe8DX0hIWJrShOHUravbrz/wJwY5pMWjnkO32z2qcBhAoHPO2cZAEJsC3oQqV 5KOw== X-Gm-Message-State: AIVw112h/5A5hEg+EB3lQ3buXrIiwc/kYH5qctrAchd4zMruKa88mYiS 4lzcFpPxSzdhplCb7E+QG7f1arM50w== X-Received: by 10.159.41.163 with SMTP id s32mr304872uas.90.1500369204354; Tue, 18 Jul 2017 02:13:24 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.118.212 with HTTP; Tue, 18 Jul 2017 02:13:23 -0700 (PDT) In-Reply-To: References: From: "Bin.Cheng" Date: Tue, 18 Jul 2017 10:13:23 +0100 Message-ID: Subject: Re: [PATCH PR81408]Turn TREE level unsafe loop optimizations warning to missed optimization message To: Richard Biener Cc: "gcc-patches@gcc.gnu.org" X-IsSubscribed: yes On Tue, Jul 18, 2017 at 9:31 AM, Richard Biener wrote: > On Tue, Jul 18, 2017 at 10:00 AM, Bin Cheng wrote: >> Hi, >> I removed unsafe loop optimization on TREE level last year, so GCC doesn't do unsafe >> loop optimizations on TREE now. All "unsafe loop optimizations" warnings reported by >> TREE optimizers are simply missed optimizations. This patch turns such warning into >> missed optimization messages. I didn't change when this will be dumped, for now it is >> when called from ivopts. >> Bootstrap and test on x86_64 and AArch64. Is it OK? > > Ok but can you change the testcase to not scan the ivopts dump but use > -fopt-info-loop-missed? > You should be able to match the output with dg-message. Thanks for reviewing. New patch with test case updated accordingly. Is it OK? Thanks, bin > > Thanks, > Richard. > >> Thanks, >> bin >> 2017-07-13 Bin Cheng >> >> PR target/81408 >> * tree-ssa-loop-niter.c (number_of_iterations_exit): Dump missed >> optimization for loop niter analysis. >> >> gcc/testsuite/ChangeLog >> 2017-07-13 Bin Cheng >> >> PR target/81408 >> * g++.dg/tree-ssa/pr81408.C: New. >> * gcc.dg/tree-ssa/pr19210-1.c: Check dump message rather than warning. diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr81408.C b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C new file mode 100644 index 0000000..f94544b --- /dev/null +++ b/gcc/testsuite/g++.dg/tree-ssa/pr81408.C @@ -0,0 +1,92 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -std=gnu++11 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */ + +namespace a { +void b () __attribute__ ((__noreturn__)); +template struct d; +template struct d +{ + typedef e f; +}; +struct g +{ + template using i = h *; +}; +} +using a::d; +template class k +{ + j l; + +public: + typename d::f operator* () {} + void operator++ () { ++l; } + j + aa () + { + return l; + } +}; +template +bool +operator!= (k o, k p2) +{ + return o.aa () != p2.aa (); +} +struct p; +namespace a { +struct F +{ + struct q + { + using ai = g::i

; + }; + using r = q::ai; +}; +class H +{ +public: + k begin (); + k end (); +}; +int s; +class I +{ +public: + void + aq (char) + { + if (s) + b (); + } +}; +class u : public I +{ +public: + void + operator<< (u o (u)) + { + o (*this); + } + u operator<< (void *); +}; +template +at +av (au o) +{ + o.aq ('\n'); +} +u ax; +} +struct p +{ + char *ay; +}; +a::H t; +void +ShowHelpListCommands () +{ + for (auto c : t) /* { dg-message "note: missed loop optimization: niters analysis .*" } */ + a::ax << c.ay << a::av; +} + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c index 3c8ee06..0fa5600 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr19210-1.c @@ -1,15 +1,15 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -Wunsafe-loop-optimizations" } */ +/* { dg-options "-O2 -fopt-info-loop-missed -Wunsafe-loop-optimizations" } */ extern void g(void); void f (unsigned n) { unsigned k; - for(k = 0;k <= n;k++) /* { dg-warning "missed loop optimization.*overflow" } */ + for(k = 0;k <= n;k++) /* { dg-message "note: missed loop optimization: niters analysis .*" } */ g(); - for(k = 0;k <= n;k += 4) /* { dg-warning "missed loop optimization.*overflow" } */ + for(k = 0;k <= n;k += 4) /* { dg-message "note: missed loop optimization: niters analysis .*" } */ g(); /* We used to get warning for this loop. However, since then # of iterations @@ -21,9 +21,9 @@ f (unsigned n) g(); /* So we need the following loop, instead. */ - for(k = 4;k <= n;k += 5) /* { dg-warning "missed loop optimization.*overflow" } */ + for(k = 4;k <= n;k += 5) /* { dg-message "note: missed loop optimization: niters analysis .*" } */ g(); - for(k = 15;k >= n;k--) /* { dg-warning "missed loop optimization.*overflow" } */ + for(k = 15;k >= n;k--) /* { dg-message "note: missed loop optimization: niters analysis .*" } */ g(); } diff --git a/gcc/tree-ssa-loop-niter.c b/gcc/tree-ssa-loop-niter.c index 5a7cab5..1421002 100644 --- a/gcc/tree-ssa-loop-niter.c +++ b/gcc/tree-ssa-loop-niter.c @@ -2378,9 +2378,9 @@ number_of_iterations_exit (struct loop *loop, edge exit, return true; if (warn) - warning_at (gimple_location_safe (stmt), - OPT_Wunsafe_loop_optimizations, - "missed loop optimization, the loop counter may overflow"); + dump_printf_loc (MSG_MISSED_OPTIMIZATION, gimple_location_safe (stmt), + "missed loop optimization: niters analysis ends up " + "with assumptions.\n"); return false; }