From patchwork Thu Jun 16 12:56:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 636375 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 3rVk0t5Hybz9sdb for ; Thu, 16 Jun 2016 22:56:45 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=nNsqmwxx; 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:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=eMrMCrp7gVUQFYvMNgxwdNJMp+/GqU8SDaD/PEPLll8A1jkCwkafJ GjsErxM9/nA7CTKzZM13S7QvCZnsJ+oIhAiYCLHrAMabChIEoBk1q8MwuxShWcn6 yQ6RDYnMxOU4SuDnMX41x6LAHdblh185WoxlXBICEqcu18cgh6hcpw= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=z7YKpQ9U0e6eXYhGbmklP5XJ2tU=; b=nNsqmwxxw2ZJ1dZsVn0J lDi7/G6zIfU6jOXMkWMiJ6sIfLHCSZMbQ1cHspXYIbMiB7lCMdSFrarluY9qB+/S QlZEWD+1m8LdTni/JHHo57btVqGydqWk/ff8SAOgNInEmsaMaIJDdhUKiEOgh8+M EZv0/Bwqhxxn65AqIQEnMUw= Received: (qmail 53411 invoked by alias); 16 Jun 2016 12:56:38 -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 53344 invoked by uid 89); 16 Jun 2016 12:56:37 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_ASCII_DIVIDERS, KAM_LAZY_DOMAIN_SECURITY, RP_MATCHES_RCVD autolearn=no version=3.3.2 spammy= X-HELO: nikam.ms.mff.cuni.cz Received: from nikam.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 16 Jun 2016 12:56:27 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 52E4E545391; Thu, 16 Jun 2016 14:56:23 +0200 (CEST) Date: Thu, 16 Jun 2016 14:56:23 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org Subject: Fix loop size estimate in tree-ssa-loop-ivcanon Message-ID: <20160616125623.GA50146@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Hi, tree_estimate_loop_size contains one extra else that prevents it from determining that the induction variable comparsion is going to be eliminated in both the peeled copies as well as the last copy. This patch fixes it (it really removes one else, but need to reformat the conditional) Bootstrapped/regtested x86_64-linux, comitted. Honza * g++.dg/vect/pr36648.cc: Disable cunrolli * tree-ssa-loop-ivcanon.c (tree_estimate_loop_size): Fix estimation of comparsions in the last iteration. Index: testsuite/g++.dg/vect/pr36648.cc =================================================================== --- testsuite/g++.dg/vect/pr36648.cc (revision 237477) +++ testsuite/g++.dg/vect/pr36648.cc (working copy) @@ -1,4 +1,5 @@ /* { dg-require-effective-target vect_float } */ +// { dg-additional-options "-fdisable-tree-cunrolli" } struct vector { Index: tree-ssa-loop-ivcanon.c =================================================================== --- tree-ssa-loop-ivcanon.c (revision 237477) +++ tree-ssa-loop-ivcanon.c (working copy) @@ -255,69 +255,73 @@ tree_estimate_loop_size (struct loop *lo /* Look for reasons why we might optimize this stmt away. */ - if (gimple_has_side_effects (stmt)) - ; - /* Exit conditional. */ - else if (exit && body[i] == exit->src - && stmt == last_stmt (exit->src)) + if (!gimple_has_side_effects (stmt)) { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Exit condition will be eliminated " - "in peeled copies.\n"); - likely_eliminated_peeled = true; - } - else if (edge_to_cancel && body[i] == edge_to_cancel->src - && stmt == last_stmt (edge_to_cancel->src)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Exit condition will be eliminated " - "in last copy.\n"); - likely_eliminated_last = true; - } - /* Sets of IV variables */ - else if (gimple_code (stmt) == GIMPLE_ASSIGN - && constant_after_peeling (gimple_assign_lhs (stmt), stmt, loop)) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Induction variable computation will" - " be folded away.\n"); - likely_eliminated = true; - } - /* Assignments of IV variables. */ - else if (gimple_code (stmt) == GIMPLE_ASSIGN - && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME - && constant_after_peeling (gimple_assign_rhs1 (stmt), stmt, - loop) - && (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS - || constant_after_peeling (gimple_assign_rhs2 (stmt), - stmt, loop))) - { - size->constant_iv = true; - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, - " Constant expression will be folded away.\n"); - likely_eliminated = true; - } - /* Conditionals. */ - else if ((gimple_code (stmt) == GIMPLE_COND - && constant_after_peeling (gimple_cond_lhs (stmt), stmt, - loop) - && constant_after_peeling (gimple_cond_rhs (stmt), stmt, - loop) - /* We don't simplify all constant compares so make sure - they are not both constant already. See PR70288. */ - && (! is_gimple_min_invariant (gimple_cond_lhs (stmt)) - || ! is_gimple_min_invariant (gimple_cond_rhs (stmt)))) - || (gimple_code (stmt) == GIMPLE_SWITCH - && constant_after_peeling (gimple_switch_index ( - as_a (stmt)), + /* Exit conditional. */ + if (exit && body[i] == exit->src + && stmt == last_stmt (exit->src)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Exit condition will be eliminated " + "in peeled copies.\n"); + likely_eliminated_peeled = true; + } + if (edge_to_cancel && body[i] == edge_to_cancel->src + && stmt == last_stmt (edge_to_cancel->src)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Exit condition will be eliminated " + "in last copy.\n"); + likely_eliminated_last = true; + } + /* Sets of IV variables */ + if (gimple_code (stmt) == GIMPLE_ASSIGN + && constant_after_peeling (gimple_assign_lhs (stmt), stmt, loop)) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Induction variable computation will" + " be folded away.\n"); + likely_eliminated = true; + } + /* Assignments of IV variables. */ + else if (gimple_code (stmt) == GIMPLE_ASSIGN + && TREE_CODE (gimple_assign_lhs (stmt)) == SSA_NAME + && constant_after_peeling (gimple_assign_rhs1 (stmt), stmt, loop) - && ! is_gimple_min_invariant - (gimple_switch_index (as_a (stmt))))) - { - if (dump_file && (dump_flags & TDF_DETAILS)) - fprintf (dump_file, " Constant conditional.\n"); - likely_eliminated = true; + && (gimple_assign_rhs_class (stmt) != GIMPLE_BINARY_RHS + || constant_after_peeling (gimple_assign_rhs2 (stmt), + stmt, loop))) + { + size->constant_iv = true; + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, + " Constant expression will be folded away.\n"); + likely_eliminated = true; + } + /* Conditionals. */ + else if ((gimple_code (stmt) == GIMPLE_COND + && constant_after_peeling (gimple_cond_lhs (stmt), stmt, + loop) + && constant_after_peeling (gimple_cond_rhs (stmt), stmt, + loop) + /* We don't simplify all constant compares so make sure + they are not both constant already. See PR70288. */ + && (! is_gimple_min_invariant (gimple_cond_lhs (stmt)) + || ! is_gimple_min_invariant + (gimple_cond_rhs (stmt)))) + || (gimple_code (stmt) == GIMPLE_SWITCH + && constant_after_peeling (gimple_switch_index ( + as_a + (stmt)), + stmt, loop) + && ! is_gimple_min_invariant + (gimple_switch_index + (as_a (stmt))))) + { + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, " Constant conditional.\n"); + likely_eliminated = true; + } } size->overall += num;