From patchwork Tue Jun 3 01:05:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 31315 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C492B203C2 for ; Tue, 3 Jun 2014 01:05:52 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf29977103obc.11 for ; Mon, 02 Jun 2014 18:05:52 -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 :in-reply-to:references:x-original-sender :x-original-authentication-results; bh=+W38NdCGDYS106dobV8hMNZeFTCREHYl7/5i1lDlg0I=; b=XXgYC9t9nyUI+PkCJowua9bzlbsRn3xBPJMqgaJuGOrZyO1bic+Hpi0DzQcrwx1/Ji GPC82KrdotrRAWc75fsR+1e+jzEGz4vTuwswdKpuN925paIVCs9OgXS6uIk597VAowE1 rO8d3WC0Va3GXgtbdvBjNefXZM8D2DU3vKpK/OUh1DE1qExZd9jC9JQfo+9c3ZJkTPPN erafneNkR46aP5A0YrOpJgGRjfGYW7gFHtMs6jzaCNJUF+r60VAInAmqrT0k+lRnicwZ 6bY5FaFBZ1nX0ICKS9jtGlnGjZ2fu4T2uPwCZrxXvj+/Ubj9F8z0tx1pfmHRUA+xuJ1G WU+w== X-Gm-Message-State: ALoCoQljcFDQbpMKs00N1kA3ZRPmecxYVnKSPLEVckXdH4VbpCOz+DRgtXZJ738n+44l+kJirgaM X-Received: by 10.43.173.71 with SMTP id ob7mr13972570icc.19.1401757552244; Mon, 02 Jun 2014 18:05:52 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.23.147 with SMTP id 19ls2345650qgp.68.gmail; Mon, 02 Jun 2014 18:05:52 -0700 (PDT) X-Received: by 10.52.125.147 with SMTP id mq19mr28114537vdb.2.1401757552147; Mon, 02 Jun 2014 18:05:52 -0700 (PDT) Received: from mail-ve0-x229.google.com (mail-ve0-x229.google.com [2607:f8b0:400c:c01::229]) by mx.google.com with ESMTPS id px2si9033051veb.37.2014.06.02.18.05.52 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 02 Jun 2014 18:05:52 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2607:f8b0:400c:c01::229 as permitted sender) client-ip=2607:f8b0:400c:c01::229; Received: by mail-ve0-f169.google.com with SMTP id jx11so6145965veb.14 for ; Mon, 02 Jun 2014 18:05:52 -0700 (PDT) X-Received: by 10.58.30.1 with SMTP id o1mr4927753veh.37.1401757551909; Mon, 02 Jun 2014 18:05:51 -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 ib8csp138930vcb; Mon, 2 Jun 2014 18:05:51 -0700 (PDT) X-Received: by 10.68.78.66 with SMTP id z2mr45302179pbw.71.1401757550940; Mon, 02 Jun 2014 18:05:50 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ln8si18102672pab.187.2014.06.02.18.05.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Jun 2014 18:05:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-369241-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 21224 invoked by alias); 3 Jun 2014 01:05:25 -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 21176 invoked by uid 89); 3 Jun 2014 01:05:23 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-HELO: mail-ig0-f172.google.com Received: from mail-ig0-f172.google.com (HELO mail-ig0-f172.google.com) (209.85.213.172) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 03 Jun 2014 01:05:22 +0000 Received: by mail-ig0-f172.google.com with SMTP id uy17so4088082igb.11 for ; Mon, 02 Jun 2014 18:05:20 -0700 (PDT) X-Received: by 10.42.179.138 with SMTP id bq10mr1148icb.85.1401757520494; Mon, 02 Jun 2014 18:05:20 -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 x13sm7591415igp.0.2014.06.02.18.05.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 02 Jun 2014 18:05:20 -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 s5315Ii3013499 (version=TLSv1/SSLv3 cipher=DHE-DSS-AES256-SHA bits=256 verify=NO); Mon, 2 Jun 2014 18:05:19 -0700 Received: (from apinski@localhost) by localhost.localdomain (8.14.3/8.14.3/Submit) id s5315IwR013498; Mon, 2 Jun 2014 18:05:18 -0700 From: Andrew Pinski To: gcc-patches@gcc.gnu.org Cc: Andrew Pinski Subject: [PATCH/AARCH64v2 2/2] Fix PR 61345: rtx_cost ICEing on simple code Date: Mon, 2 Jun 2014 18:05:17 -0700 Message-Id: <1401757517-13460-2-git-send-email-apinski@cavium.com> In-Reply-To: <1401757517-13460-1-git-send-email-apinski@cavium.com> References: <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::229 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 Hi, The problem here is aarch64_rtx_costs for IF_THEN_ELSE does not handle the case where the first operand is a non comparison. This happens when the combine is combing a few RTLs and calling set_src_cost to check the costs of the newly created rtl. OK? Built and tested on aarch64-elf with no regressions. Thanks, Andrew Pinski ChangeLog: * config/aarch64/aarch64.c (aarch64_if_then_else_costs): Allow non comparisons for OP0. testsuite/ChangeLog: * gcc.c-torture/compile/20140528-1.c: New testcase. --- gcc/config/aarch64/aarch64.c | 36 ++++++++++++++------- gcc/testsuite/gcc.c-torture/compile/20140528-1.c | 9 +++++ 2 files changed, 33 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/compile/20140528-1.c diff --git a/gcc/config/aarch64/aarch64.c b/gcc/config/aarch64/aarch64.c index 77a6706..ce4eb3c 100644 --- a/gcc/config/aarch64/aarch64.c +++ b/gcc/config/aarch64/aarch64.c @@ -4855,19 +4855,33 @@ aarch64_rtx_arith_op_extract_p (rtx x, enum machine_mode mode) static bool aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) { + rtx inner; + rtx comparator; + enum rtx_code cmpcode; + + if (COMPARISON_P (op0)) + { + inner = XEXP (op0, 0); + comparator = XEXP (op0, 1); + cmpcode = GET_CODE (op0); + } + else + { + inner = op0; + comparator = const0_rtx; + cmpcode = NE; + } + if (GET_CODE (op1) == PC || GET_CODE (op2) == PC) { /* Conditional branch. */ - if (GET_MODE_CLASS (GET_MODE (XEXP (op0, 0))) == MODE_CC) + if (GET_MODE_CLASS (GET_MODE (inner)) == MODE_CC) return true; else { - if (GET_CODE (op0) == NE - || GET_CODE (op0) == EQ) + if (cmpcode == NE + || cmpcode == EQ) { - rtx inner = XEXP (op0, 0); - rtx comparator = XEXP (op0, 1); - if (comparator == const0_rtx) { /* TBZ/TBNZ/CBZ/CBNZ. */ @@ -4877,23 +4891,21 @@ aarch64_if_then_else_costs (rtx op0, rtx op1, rtx op2, int *cost, bool speed) 0, speed); else /* CBZ/CBNZ. */ - *cost += rtx_cost (inner, GET_CODE (op0), 0, speed); + *cost += rtx_cost (inner, cmpcode, 0, speed); return true; } } - else if (GET_CODE (op0) == LT - || GET_CODE (op0) == GE) + else if (cmpcode == LT + || cmpcode == 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) + else if (GET_MODE_CLASS (GET_MODE (inner)) == MODE_CC) { /* It's a conditional operation based on the status flags, so it must be some flavor of CSEL. */ diff --git a/gcc/testsuite/gcc.c-torture/compile/20140528-1.c b/gcc/testsuite/gcc.c-torture/compile/20140528-1.c new file mode 100644 index 0000000..d227802 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/20140528-1.c @@ -0,0 +1,9 @@ +unsigned f(unsigned flags, unsigned capabilities) +{ + unsigned gfp_mask; + unsigned gfp_notmask = 0; + gfp_mask = flags & ((1 << 25) - 1); + if (!(capabilities & 0x00000001)) + gfp_mask |= 0x1000000u; + return (gfp_mask & ~gfp_notmask); +}