From patchwork Tue Jun 3 01:05:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 31314 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f200.google.com (mail-ie0-f200.google.com [209.85.223.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 708E8203C2 for ; Tue, 3 Jun 2014 01:05:39 +0000 (UTC) Received: by mail-ie0-f200.google.com with SMTP id y20sf31485801ier.3 for ; Mon, 02 Jun 2014 18:05:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-archive:list-post :list-help:sender:delivered-to:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results; bh=o78ufqgJwz1vbX9COQwARYPokGcrLOUAINhFwVg1PJs=; b=QhFIt3aOqprblW+18x8EDYESNvNrGBMIme8t7XFQFrBB01TYyGl//nm8Hn5WXtfMmK f7PoImHAs2uMaWibD64sX8JvCn9zTbeJ/DmVQAg51FZJwny5P0UF9j2V+41rY6sc7lqP NO8BASQvZKPNOeQ2NOTJpDbPbAE7OHSByfGCsRRIanaw/KsptiowBR018y97ItiKDPjT yw+6KKDY7g8fvDxTmsPmLEyBboXAeg606qUYgWP+maJRA1R3wk6am4HjTfwVdqRrFy/f p4yGhB96OYFiCjkj3lsdh0XxAMWvMSzwfFi+MgZw2y1A9m6Y40pCYqKO6Uxe6ITkiZAs /kmA== X-Gm-Message-State: ALoCoQl1jx2d9EQN4QRvLCQejKKI9C/4K97uBNGzhrOL4h1/ZOw8XL3SsbXfjkELCVk/FX3KBWqD X-Received: by 10.42.92.69 with SMTP id s5mr13628068icm.20.1401757539149; Mon, 02 Jun 2014 18:05:39 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.33 with SMTP id e30ls2381694qge.89.gmail; Mon, 02 Jun 2014 18:05:39 -0700 (PDT) X-Received: by 10.58.74.38 with SMTP id q6mr32644822vev.7.1401757539045; Mon, 02 Jun 2014 18:05:39 -0700 (PDT) Received: from mail-ve0-x231.google.com (mail-ve0-x231.google.com [2607:f8b0:400c:c01::231]) by mx.google.com with ESMTPS id t15si9026996vew.65.2014.06.02.18.05.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 18:05:38 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::231 as permitted sender) client-ip=2607:f8b0:400c:c01::231; Received: by mail-ve0-f177.google.com with SMTP id db11so6071151veb.22 for ; Mon, 02 Jun 2014 18:05:38 -0700 (PDT) X-Received: by 10.221.7.71 with SMTP id on7mr33896477vcb.18.1401757538834; Mon, 02 Jun 2014 18:05:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp138914vcb; Mon, 2 Jun 2014 18:05:38 -0700 (PDT) X-Received: by 10.68.227.4 with SMTP id rw4mr44681812pbc.3.1401757538055; Mon, 02 Jun 2014 18:05:38 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id pj5si17858824pbb.69.2014.06.02.18.05.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 18:05:38 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-369240-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 21202 invoked by alias); 3 Jun 2014 01:05:24 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 21131 invoked by uid 89); 3 Jun 2014 01:05:23 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-ie0-f180.google.com Received: from mail-ie0-f180.google.com (HELO mail-ie0-f180.google.com) (209.85.223.180) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 03 Jun 2014 01:05:21 +0000 Received: by mail-ie0-f180.google.com with SMTP id tp5so5127623ieb.25 for ; Mon, 02 Jun 2014 18:05:19 -0700 (PDT) X-Received: by 10.50.128.162 with SMTP id np2mr24121880igb.22.1401757519729; Mon, 02 Jun 2014 18:05:19 -0700 (PDT) Received: from localhost.localdomain (64.2.3.195.ptr.us.xo.net. [64.2.3.195]) by mx.google.com with ESMTPSA id b3sm18780015igl.3.2014.06.02.18.05.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Jun 2014 18:05:19 -0700 (PDT) Received: from localhost.localdomain (apinskidesktop [127.0.0.1]) by localhost.localdomain (8.14.3/8.14.3/Debian-9.4) with ESMTP id s5315ITh013495 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Mon, 2 Jun 2014 18:05:18 -0700 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id s5315IlF013494; Mon, 2 Jun 2014 18:05:18 -0700 From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH/AARCH64v2 1/2] Factor out IF_THEN_ELSE case from aarch64_rtx_costs Date: Mon, 2 Jun 2014 18:05:16 -0700 Message-Id: <1401757517-13460-1-git-send-email-apinski@cavium.com> X-Original-Sender: apinski@cavium.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::231 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 This factors out the IF_THEN_ELSE from aarch64_rtx_costs as that function was getting too large. OK? Build and tested for aarch64-elf with no regressions. Thanks, Andrew Pinski ChangeLog: * config/aarch64/aarch64.c (aarch64_if_then_else_costs): New function. (aarch64_rtx_costs): Use aarch64_if_then_else_costs. --- gcc/config/aarch64/aarch64.c | 126 ++++++++++++++++++++++-------------------- 1 files changed, 66 insertions(+), 60 deletions(-) diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index bb33304..77a6706 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4849,6 +4849,70 @@ aarch64_rtx_arith_op_extract_p (rtx x, enum machine_mode mode) return false; } +/* Calculate the cost of calculating (if_then_else (OP0) (OP1) (OP2)), + storing it in *COST. Result is true if the total cost of the operation + has now been calculated. */ +static bool +aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) +{ + if (GET_CODE (op1) == PC || GET_CODE (op2) == PC) + { + /* Conditional branch. */ + if (GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) + return true; + else + { + if (GET_CODE (op0) == NE + || GET_CODE (op0) == EQ) + { + rtx inner = XEXP (op0, 0); + rtx comparator = XEXP (op0, 1); + + if (comparator == const0_rtx) + { + /* TBZ/TBNZ/CBZ/CBNZ. */ + if (GET_CODE (inner) == ZERO_EXTRACT) + /* TBZ/TBNZ. */ + *cost += rtx_cost (XEXP (inner, 0), ZERO_EXTRACT, + 0, speed); + else + /* CBZ/CBNZ. */ + *cost += rtx_cost (inner, GET_CODE (op0), 0, speed); + + return true; + } + } + else if (GET_CODE (op0) == LT + || GET_CODE (op0) == GE) + { + rtx comparator = XEXP (op0, 1); + + /* TBZ/TBNZ. */ + if (comparator == const0_rtx) + return true; + } + } + } + else if (GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) + { + /* It's a conditional operation based on the status flags, + so it must be some flavor of CSEL. */ + + /* CSNEG, CSINV, and CSINC are handled for free as part of CSEL. */ + if (GET_CODE (op1) == NEG + || GET_CODE (op1) == NOT + || (GET_CODE (op1) == PLUS && XEXP (op1, 1) == const1_rtx)) + op1 = XEXP (op1, 0); + + *cost += rtx_cost (op1, IF_THEN_ELSE, 1, speed); + *cost += rtx_cost (op2, IF_THEN_ELSE, 2, speed); + return true; + } + + /* We don't know what this is, cost all operands. */ + return false; +} + /* Calculate the cost of calculating X, storing it in *COST. Result is true if the total cost of the operation has now been calculated. */ static bool @@ -5583,66 +5647,8 @@ cost_plus: return false; /* All arguments need to be in registers. */ case IF_THEN_ELSE: - op2 = XEXP (x, 2); - op0 = XEXP (x, 0); - op1 = XEXP (x, 1); - - if (GET_CODE (op1) == PC || GET_CODE (op2) == PC) - { - /* Conditional branch. */ - if (GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) - return true; - else - { - if (GET_CODE (op0) == NE - || GET_CODE (op0) == EQ) - { - rtx inner = XEXP (op0, 0); - rtx comparator = XEXP (op0, 1); - - if (comparator == const0_rtx) - { - /* TBZ/TBNZ/CBZ/CBNZ. */ - if (GET_CODE (inner) == ZERO_EXTRACT) - /* TBZ/TBNZ. */ - *cost += rtx_cost (XEXP (inner, 0), ZERO_EXTRACT, - 0, speed); - else - /* CBZ/CBNZ. */ - *cost += rtx_cost (inner, GET_CODE (op0), 0, speed); - - return true; - } - } - else if (GET_CODE (op0) == LT - || GET_CODE (op0) == GE) - { - rtx comparator = XEXP (op0, 1); - - /* TBZ/TBNZ. */ - if (comparator == const0_rtx) - return true; - } - } - } - else if (GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) - { - /* It's a conditional operation based on the status flags, - so it must be some flavor of CSEL. */ - - /* CSNEG, CSINV, and CSINC are handled for free as part of CSEL. */ - if (GET_CODE (op1) == NEG - || GET_CODE (op1) == NOT - || (GET_CODE (op1) == PLUS && XEXP (op1, 1) == const1_rtx)) - op1 = XEXP (op1, 0); - - *cost += rtx_cost (op1, IF_THEN_ELSE, 1, speed); - *cost += rtx_cost (op2, IF_THEN_ELSE, 2, speed); - return true; - } - - /* We don't know what this is, cost all operands. */ - return false; + return aarch64_if_then_else_costs (XEXP (x, 0), XEXP (x, 1), + XEXP (x, 2), cost, speed); case EQ: case NE: