From patchwork Wed Apr 12 15:23:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 750052 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 3w376X381Xz9sDG for ; Thu, 13 Apr 2017 01:25:56 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jT75C+tR"; 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:from :to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=i8kW4OBF+pFTnnm4pEi AKCSfLLFrybraHiq+feHyshQNilSCtsuAkmc0ml3266zk2u3TWZ5dIrHlTH7k1s7 u0iDXtwIC8XF5FU2KBmE3m4uh74Ngx79h8fIXPkhL/wdLbEjkDikleNQsPgYEhpo gIRVUxo8/CQ2YDeUoBXG9d68= 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 :in-reply-to:references; s=default; bh=ihgCS3N8Q4Qe8Z8DbYP3aH2zr o8=; b=jT75C+tRW9XO5+XW3PYHTjLLEeuniuhH4TrAaXVLB/7hU/3kAH80E0KhT 8Fx4a75xvAvUYA95nV6m8madgeuc6ngyjJ4NBW1rZms0NOYmyo1MMnUPFhy9sIcg n/+NrY9ZA15Zjz9tj4wKDrAR/pszEhppHJGo1DIZfK6zmtp29I= Received: (qmail 16684 invoked by alias); 12 Apr 2017 15:24:46 -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 110952 invoked by uid 89); 12 Apr 2017 15:24:19 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=lp, bbb, 2411, ppp X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 12 Apr 2017 15:24:17 +0000 Received: by mail-wr0-f175.google.com with SMTP id z109so19791304wrb.1 for ; Wed, 12 Apr 2017 08:24:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=8DEkEcDUm5gUsNBhnrg6SnpVipXGToKEJ8ffYdoLVew=; b=EtOZ6B2TwkwXyZih0wf5WgeBSellxnhsenYSzqFtkce6n5bLQrLJdvFLNmEx+mwY+Q cwk5ZsjhqM/I0IOyPrC53vmQHFtSjx1QTObUn3LYKfVSjTeisPrBW8WWTQ58y1Yvt5yY wdFJBzNJcy2jjgyy6Mr5owAntFYV7eaTb2pwVALKtaDTwY4mmC6YZZVQtu1H8aDIn9q0 vMFdBVYnu+Z0r+MINU8+hGRiYWTOFl0InfYG6sP4b9AIfvkRPPessc7NOV5psHf+I32A XJ1p8UK+Od8JraeTkWgkcUQtLop3tzgCKnlqdjoEUpRAZM9ycRIubizjzxJEq8X7jrtP 3fRA== X-Gm-Message-State: AN3rC/5VeI7cxy798jspTMOOR+oKc+BNVt1n7pV+CxzQVZ+qpCPhNEVR8S3n38skQtHSoA== X-Received: by 10.223.172.228 with SMTP id o91mr3473962wrc.122.1492010649135; Wed, 12 Apr 2017 08:24:09 -0700 (PDT) Received: from localhost (host86-190-190-198.range86-190.btcentralplus.com. [86.190.190.198]) by smtp.gmail.com with ESMTPSA id 3sm19801900wrv.33.2017.04.12.08.24.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Apr 2017 08:24:08 -0700 (PDT) From: Andrew Burgess To: gcc-patches@gcc.gnu.org Cc: guybe@mellanox.com, Claudiu.Zissulescu@synopsys.com, Andrew Burgess Subject: [PATCH 2/2] arc: Fix for loop end detection Date: Wed, 12 Apr 2017 16:23:54 +0100 Message-Id: <60f778afbc7621347ff1e817bbf78c113dd8c83b.1492010055.git.andrew.burgess@embecosm.com> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes We use a negative ID number to link together the doloop_begin and doloop_end instructions. This negative ID number is setup within doloop_begin, at this point the ID is stored into the loop end instruction (doloop_end_i) and placed into the doloop_begin_i instruction. In arc.c (arc_reorg) we extract the ID from the doloop_end_i instruction in order to find the matching doloop_begin_i instruction, though the ID is only used in some cases. Currently in arc_reorg when we extract the ID we negate it. This negation is invalid. The ID stored in both doloop_end_i and doloop_begin_i is already negative, the negation in arc_reorg means that if we need to use the ID to find the doloop_begin_i then we will never find it (as the IDs will never match). This commit removes the unneeded negation, moves the extraction of the ID into a more appropriately scoped block and adds a new test for this issue. gcc/ChangeLog: * config/arc/arc.c (arc_reorg): Move loop_end_id into a more local block, and do not negate it, the stored id is already negative. gcc/testsuite/ChangeLog: * gcc.target/arc/loop-1.c: New file. --- gcc/ChangeLog | 6 +++++ gcc/config/arc/arc.c | 5 ++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/arc/loop-1.c | 45 +++++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arc/loop-1.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 0563a74..39b198d 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -6573,8 +6573,6 @@ arc_reorg (void) rtx_insn *lp_simple = NULL; rtx_insn *next = NULL; rtx op0 = XEXP (XVECEXP (PATTERN (insn), 0, 1), 0); - HOST_WIDE_INT loop_end_id - = -INTVAL (XEXP (XVECEXP (PATTERN (insn), 0, 4), 0)); int seen_label = 0; for (lp = prev; @@ -6585,6 +6583,9 @@ arc_reorg (void) if (!lp || !NONJUMP_INSN_P (lp) || dead_or_set_regno_p (lp, LP_COUNT)) { + HOST_WIDE_INT loop_end_id + = INTVAL (XEXP (XVECEXP (PATTERN (insn), 0, 4), 0)); + for (prev = next = insn, lp = NULL ; prev || next;) { if (prev) diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c new file mode 100644 index 0000000..1afe8eb --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-1.c @@ -0,0 +1,45 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* This case would fail to make use of the zero-overhead loop + instruction at one time due to a bug. */ + +extern char a[]; + +struct some_t +{ + struct + { + int aaa; + short bbb; + char ccc; + char ddd; + } ppp[8]; + + int www[1]; +}; + +int b; + +void +some_function () +{ + struct some_t *tmp = (struct some_t *) a; + + while ((*tmp).ppp[b].ccc) + while(0); + + for (; b; b++) + { + if (tmp->ppp[b].ccc) + { + int c = tmp->ppp[b].bbb; + int d = tmp->ppp[b].aaa; + int e = d - tmp->www[c]; + if (e) + tmp->ppp[b].ddd = 1; + } + } +} + +/* { dg-final { scan-assembler "\[^\n\]+lp \\.L__GCC__" } } */