From patchwork Mon Sep 1 13:30:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 384832 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 0B2DB14009E for ; Mon, 1 Sep 2014 23:34:25 +1000 (EST) 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=jyGPHBONQDAg3zxp6bcPFKKyYnCpIibLjAMRahyH9xhw4MCvAY+iu JSXSluQL+rEw0ydRARPEY4rCIe8iJJNNJn1mz+XPxUOC2Ji+q5D1waD9FNDRPwrU 7zLG84W0r2yRsEvAy72trlD5cnDngN2+CstgUE3JLDB3LJbpH1BQyU= 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=d3+x5Ka2voHcdLLjcxh7nIfFaPc=; b=PqhXoVASLOg254MVl38o J+Gyq9sUHFbFVVZbCrooxQquJJJHsj2qZCElMeP2TNmtfPiI+zUxeD5BeuRKrFIQ DZCgH8zRFs26OEOhFsyT1h0MCKnFP3+/1BeIhw6lWvaucyshmXeWvcuTwjCkCVbc sM8YcwnBln4D9DVSrE6fhVg= Received: (qmail 27662 invoked by alias); 1 Sep 2014 13:34:16 -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 27650 invoked by uid 89); 1 Sep 2014 13:34:15 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD autolearn=ham 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; Mon, 01 Sep 2014 13:34:05 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E9AC7AD2C for ; Mon, 1 Sep 2014 13:34:01 +0000 (UTC) Date: Mon, 1 Sep 2014 15:30:37 +0200 (CEST) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH] Speedup PRE Message-ID: User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 This removes redundant "folding" code from reference phi-translation and it avoids allocating the "translated" operands vector if it is identical to the original one. Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk. Richard. 2014-09-01 Richard Biener * tree-ssa-pre.c (phi_translate_1): Avoid re-allocating the operands vector in most cases. Remove redundant code. Index: trunk/gcc/tree-ssa-pre.c =================================================================== --- trunk.orig/gcc/tree-ssa-pre.c 2014-09-01 13:32:10.305710553 +0200 +++ trunk/gcc/tree-ssa-pre.c 2014-09-01 13:25:48.774736821 +0200 @@ -1536,12 +1536,11 @@ phi_translate_1 (pre_expr expr, bitmap_s tree newvuse = vuse; vec newoperands = vNULL; bool changed = false, same_valid = true; - unsigned int i, j, n; + unsigned int i, n; vn_reference_op_t operand; vn_reference_t newref; - for (i = 0, j = 0; - operands.iterate (i, &operand); i++, j++) + for (i = 0; operands.iterate (i, &operand); i++) { pre_expr opresult; pre_expr leader; @@ -1585,6 +1584,8 @@ phi_translate_1 (pre_expr expr, bitmap_s newoperands.release (); return NULL; } + if (!changed) + continue; if (!newoperands.exists ()) newoperands = operands.copy (); /* We may have changed from an SSA_NAME to a constant */ @@ -1594,36 +1595,14 @@ phi_translate_1 (pre_expr expr, bitmap_s newop.op0 = op[0]; newop.op1 = op[1]; newop.op2 = op[2]; - /* If it transforms a non-constant ARRAY_REF into a constant - one, adjust the constant offset. */ - if (newop.opcode == ARRAY_REF - && newop.off == -1 - && TREE_CODE (op[0]) == INTEGER_CST - && TREE_CODE (op[1]) == INTEGER_CST - && TREE_CODE (op[2]) == INTEGER_CST) - { - offset_int off = ((wi::to_offset (op[0]) - - wi::to_offset (op[1])) - * wi::to_offset (op[2])); - if (wi::fits_shwi_p (off)) - newop.off = off.to_shwi (); - } - newoperands[j] = newop; - /* If it transforms from an SSA_NAME to an address, fold with - a preceding indirect reference. */ - if (j > 0 && op[0] && TREE_CODE (op[0]) == ADDR_EXPR - && newoperands[j - 1].opcode == MEM_REF) - vn_reference_fold_indirect (&newoperands, &j); - } - if (i != operands.length ()) - { - newoperands.release (); - return NULL; + newoperands[i] = newop; } + gcc_checking_assert (i == operands.length ()); if (vuse) { - newvuse = translate_vuse_through_block (newoperands, + newvuse = translate_vuse_through_block (newoperands.exists () + ? newoperands : operands, ref->set, ref->type, vuse, phiblock, pred, &same_valid); @@ -1641,7 +1620,8 @@ phi_translate_1 (pre_expr expr, bitmap_s tree result = vn_reference_lookup_pieces (newvuse, ref->set, ref->type, - newoperands, + newoperands.exists () + ? newoperands : operands, &newref, VN_WALK); if (result) newoperands.release (); @@ -1700,11 +1680,13 @@ phi_translate_1 (pre_expr expr, bitmap_s } else new_val_id = ref->value_id; + if (!newoperands.exists ()) + newoperands = operands.copy (); newref = vn_reference_insert_pieces (newvuse, ref->set, ref->type, newoperands, result, new_val_id); - newoperands.create (0); + newoperands = vNULL; PRE_EXPR_REFERENCE (expr) = newref; constant = fully_constant_expression (expr); if (constant != expr)