From patchwork Fri May 29 12:41:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 477825 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 397CA140F8B for ; Fri, 29 May 2015 22:41:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=sOyUMrpZ; 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=jR7lxE3CPjyFvEsZ23lk4OHy7El5WRrRUyU3mjW5g5rcd9NqqasO4 HnGVrGaqgy1fXEO+fqMVlio/0YLbrN66OErm84aTnRmqAxQM0M+m39kQ7wbTSnCn y4/fLf2UgXK5EcFDee25HTvItPubYDJkx1oVliAbs9FyfD/I1NXSVg= 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=xXhGq4QYDVQkp1093QKX4W+5bVQ=; b=sOyUMrpZcNmNSLKUL/Xb VK2aX1YMCiZ3HJUf6Jhm6tt8nQrEg3EaRhYKrC96pVGbR8fIYZQjXpXrhb/F20rW Oxxozszf5DJU93c2ij40ecE7ymLdc8slh8DukjExGsHZz/GUjMfyF8PmfOZLRRnM IZCH/0sonJhRTRFfeKl2C8c= Received: (qmail 110291 invoked by alias); 29 May 2015 12:41:33 -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 110273 invoked by uid 89); 29 May 2015 12:41:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx2.suse.de Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 29 May 2015 12:41:31 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 9C22CABB5 for ; Fri, 29 May 2015 12:41:28 +0000 (UTC) Date: Fri, 29 May 2015 14:41:28 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] TLC to reassoc get_rank Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Bootstrapped on x86_64-unknown-linux-gnu, testing in progress. Richard. 2015-05-29 Richard Biener * tree-ssa-reassoc.c (get_rank): Simplify. Index: gcc/tree-ssa-reassoc.c =================================================================== --- gcc/tree-ssa-reassoc.c (revision 223818) +++ gcc/tree-ssa-reassoc.c (working copy) @@ -417,10 +417,6 @@ insert_operand_rank (tree e, long rank) static long get_rank (tree e) { - /* Constants have rank 0. */ - if (is_gimple_min_invariant (e)) - return 0; - /* SSA_NAME's have the rank of the expression they are the result of. For globals and uninitialized values, the rank is 0. @@ -460,9 +456,9 @@ get_rank (tree e) if (TREE_CODE (e) == SSA_NAME) { + ssa_op_iter iter; gimple stmt; long rank; - int i, n; tree op; if (SSA_NAME_IS_DEFAULT_DEF (e)) @@ -472,8 +468,7 @@ get_rank (tree e) if (gimple_code (stmt) == GIMPLE_PHI) return phi_rank (stmt); - if (!is_gimple_assign (stmt) - || gimple_vdef (stmt)) + if (!is_gimple_assign (stmt)) return bb_rank[gimple_bb (stmt)->index]; /* If we already have a rank for this expression, use that. */ @@ -484,34 +479,12 @@ get_rank (tree e) /* Otherwise, find the maximum rank for the operands. As an exception, remove the bias from loop-carried phis when propagating the rank so that dependent operations are not also biased. */ + /* Simply walk over all SSA uses - this takes advatage of the + fact that non-SSA operands are is_gimple_min_invariant and + thus have rank 0. */ rank = 0; - if (gimple_assign_single_p (stmt)) - { - tree rhs = gimple_assign_rhs1 (stmt); - n = TREE_OPERAND_LENGTH (rhs); - if (n == 0) - rank = propagate_rank (rank, rhs); - else - { - for (i = 0; i < n; i++) - { - op = TREE_OPERAND (rhs, i); - - if (op != NULL_TREE) - rank = propagate_rank (rank, op); - } - } - } - else - { - n = gimple_num_ops (stmt); - for (i = 1; i < n; i++) - { - op = gimple_op (stmt, i); - gcc_assert (op); - rank = propagate_rank (rank, op); - } - } + FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE) + rank = propagate_rank (rank, op); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -525,7 +498,11 @@ get_rank (tree e) return (rank + 1); } - /* Globals, etc, are rank 0 */ + /* Constants have rank 0. */ + if (is_gimple_min_invariant (e)) + return 0; + + /* Constants, globals, etc., are rank 0 */ return 0; }