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: 355116 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 BA17F140092 for ; Tue, 3 Jun 2014 11:05:45 +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:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=RLtcClMUvfmxnq4mncal+6ok/V/vzJjwC35nrkAWuwPvNf9GG/xp3 zLrqR5nwlNYuput3Nv8Dn3mJX0DFrNqoGU6TxuPPDqCYgJYgRTYrOIvRKRRJSnTO 3S5xKVH5RMbHpJoZJGLQpc7bjYWZawVk3bYjY6c6uNz9RRXhaxnJ3g= 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:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=gEqLvvdnr1UQ4HGX391XG/hd8rk=; b=jMxrio7OntAWwSXKmp4a hLL5yLH1FfToZ/iyjitDWNOaPzEm5wap57JHFC63DvZPx5WT+W3iHhvXCGKrrpOo i5it++0s2/pTs0EH57AOZ0wN4fi4iMQr/ZyY6fE2EQ0i7KlmaDEOeiW75TQ/jy4Y DJbP5cahYrIXN+8G7T4XN1A= Received: (qmail 21224 invoked by alias); 3 Jun 2014 01:05:25 -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 21176 invoked by uid 89); 3 Jun 2014 01:05:23 -0000 Authentication-Results: sourceware.org; auth=none 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-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+W38NdCGDYS106dobV8hMNZeFTCREHYl7/5i1lDlg0I=; b=MdbfhONVF/WyVCHGa1ovaYtvbQBQdcoe046Z+ejDOmKpwm6KyZ5/Topu7DjrGgBn0W ChgoN5SDvDq/9z5IT3ma8vk5n1sZCe4o5A2PsqX6MNcnl19qePdU3ENWoWJ9N3J7CyEw GyuHR0mfEAoShLgjpdSpBtdRM0JpBcEcHQvgwX8St8frUMENOfW3hcz8FGfRhaaEPAJS X5g4Fd4viMkGR9OMuiiUyaePYVIw/+mQzrKPkXtutTiUDK6w2Un5a79ckZqfJ9sdH0zA ZstQfepo4sPJcWGmhzgTCPdiZGW2mctjJ424XD29i76U04bduFOnPvaaysd3MLjUuDG7 MGqA== X-Gm-Message-State: ALoCoQnWz38q2NOrlD+T1Wy1u0wkd4o6q8mvv3PWg5T673jLfyV8KqherX0tu2TLYvot9r3C4U5F 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> 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); +}