From patchwork Fri Feb 8 11:08:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1038567 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-495503-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="uuqgmIfR"; 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 43wsrZ330Yz9sLw for ; Fri, 8 Feb 2019 22:09:17 +1100 (AEDT) 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=Nb9tpZnkIW2nGSfE k2hTDe5Nv33iCc6ioDZPyNt8D2vZBH5OBKhEssGU1/nt8IL4FY3gPjBnvXEe+b8i HKWQCZ24WNRxjR6mnGchFsFbI/yeF5gqTYyLNnu5Oy2VYF9nNtdl2efKZ6HhmG7M id1rIKxq8PD11Ccsofu22sqWUYs= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=nAPtmONzPThsig/+ZP8APF gGzjI=; b=uuqgmIfRgADpmaPReQzwCPHQN0rpnFjELSt5FJqiZ00+hihpl1IT9i 65zJL3dzD89gLQt6YyDHMlvu4qc4s6p/brEgmmxuayYA+4wQWbvdR2EnVM56NQqh 2BLskD+hLknsjkLxGqzl5ie42YTGfvNbw3lVke1pDx7F+3M0n1puQ= Received: (qmail 52068 invoked by alias); 8 Feb 2019 11:09:10 -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 51841 invoked by uid 89); 8 Feb 2019 11:09:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=64787, transc, UD:trans.c, trans.c X-HELO: smtp.eu.adacore.com Received: from mel.act-europe.fr (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 08 Feb 2019 11:09:09 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 0556181391 for ; Fri, 8 Feb 2019 12:09:07 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qgIZMBM9LOoF for ; Fri, 8 Feb 2019 12:09:06 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id D8B7480004 for ; Fri, 8 Feb 2019 12:09:06 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix profile mismatch with -fprofile-{generate,use} at -O2 Date: Fri, 08 Feb 2019 12:08:40 +0100 Message-ID: <1786582.xGmHWxF9j1@polaris> MIME-Version: 1.0 This is a regression present on all active branches: in some cases, you get bogus profile mismatches with -fprofile-{generate,use} at -O2 because some -O3 optimizations are automatically enabled by -fprofile-use. Tested on x86_64-suse-linux, applied on all active branches. 2019-02-08 Eric Botcazou * gcc-interface/trans.c (Regular_Loop_to_gnu): Replace tests on individual flag_unswitch_loops and flag_tree_loop_vectorize switches with test on global optimize switch. (Raise_Error_to_gnu): Likewise. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 268508) +++ gcc-interface/trans.c (working copy) @@ -3787,7 +3787,7 @@ Regular_Loop_to_gnu (Node_Id gnat_node, unswitching is enabled, do not require the loop bounds to be also invariant, as their evaluation will still be ahead of the loop. */ if (vec_safe_length (gnu_loop_info->checks) > 0 - && (make_invariant (&gnu_low, &gnu_high) || flag_unswitch_loops)) + && (make_invariant (&gnu_low, &gnu_high) || optimize >= 3)) { struct range_check_info_d *rci; unsigned int i, n_remaining_checks = 0; @@ -3840,22 +3840,21 @@ Regular_Loop_to_gnu (Node_Id gnat_node, /* Note that loop unswitching can only be applied a small number of times to a given loop (PARAM_MAX_UNSWITCH_LEVEL default to 3). */ if (IN_RANGE (n_remaining_checks, 1, 3) - && optimize > 1 + && optimize >= 2 && !optimize_size) FOR_EACH_VEC_ELT (*gnu_loop_info->checks, i, rci) if (rci->invariant_cond != boolean_false_node) { TREE_OPERAND (rci->inserted_cond, 0) = rci->invariant_cond; - if (flag_unswitch_loops) + if (optimize >= 3) add_stmt_with_node_force (rci->inserted_cond, gnat_node); } } /* Second, if loop vectorization is enabled and the iterations of the loop can easily be proved as independent, mark the loop. */ - if (optimize - && flag_tree_loop_vectorize + if (optimize >= 3 && independent_iterations_p (LOOP_STMT_BODY (gnu_loop_stmt))) LOOP_STMT_IVDEP (gnu_loop_stmt) = 1; @@ -6478,7 +6477,7 @@ Raise_Error_to_gnu (Node_Id gnat_node, t = build1 (SAVE_EXPR, boolean_type_node, boolean_true_node); vec_safe_push (loop->checks, rci); gnu_cond = build_noreturn_cond (gnat_to_gnu (gnat_cond)); - if (flag_unswitch_loops) + if (optimize >= 3) gnu_cond = build_binary_op (TRUTH_ANDIF_EXPR, boolean_type_node, rci->inserted_cond,