From patchwork Mon Nov 27 11:09:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 841631 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467935-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="fUFYJWUb"; dkim-atps=neutral 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 3ylkhX6ZN1z9rxl for ; Mon, 27 Nov 2017 22:14:20 +1100 (AEDT) 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 :mime-version:content-type; q=dns; s=default; b=D4+Z3gq1dOPcJPaZ uJFXFXQjtP1Ne6NEJuSjX9AlGkheYnn1rOmYBQPuBl0IFIxVL2URMadzAMk4jCEC oS8nsyF/Uf9AyYy7jN3XmJxEa/ZTW9vKSzmcAaYoD0Z2znrZYLdtkf3xFuiLz9We ehp9+HNhTNoX/mrxxHqO4suXx4E= 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 :mime-version:content-type; s=default; bh=7ZoXbDowlZZ9vfsSANzLV1 dy5us=; b=fUFYJWUbjRaO69oqLH6E8VeS4HZim3rKCi/C0QGxHImK6aJFLuw1/t vnAc1JJMhsM0btCRGHAVKvFg9WVGyPBtqtFHANaaZMSuBuuPr3zDvBUf9bEvCnPR zMu8HVKrcVgndEYtbH/JDQW0MG2RDILYwlUWhwY6gvheKdKqww9bk= Received: (qmail 115453 invoked by alias); 27 Nov 2017 11:14:09 -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 115440 invoked by uid 89); 27 Nov 2017 11:14:08 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RCVD_IN_DNSWL_NONE, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*RU:sk:smtprel, Hx-spam-relays-external:sk:smtprel, HX-HELO:sk:smtprel, Hx-spam-relays-external:sk:mailhos X-HELO: smtprelay.synopsys.com Received: from smtprelay.synopsys.com (HELO smtprelay.synopsys.com) (198.182.60.111) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 27 Nov 2017 11:14:07 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 3080210C1991; Mon, 27 Nov 2017 03:14:04 -0800 (PST) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id C6260CFD; Mon, 27 Nov 2017 03:14:04 -0800 (PST) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1.internal.synopsys.com [10.12.239.235]) by mailhost.synopsys.com (Postfix) with ESMTP id B79BBCFB; Mon, 27 Nov 2017 03:14:04 -0800 (PST) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by us01wehtc1.internal.synopsys.com (10.12.239.235) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 27 Nov 2017 03:14:04 -0800 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.103) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 27 Nov 2017 16:44:01 +0530 Received: from nl20droid1.internal.synopsys.com (10.100.24.228) by IN01WEHTCA.internal.synopsys.com (10.144.199.243) with Microsoft SMTP Server (TLS) id 14.3.266.1; Mon, 27 Nov 2017 16:44:01 +0530 From: Claudiu Zissulescu To: CC: , , , Claudiu Zissulescu Subject: [PATCH 03/10] [ARC] Don't allow the last ZOL insn to be in a delay slot. Date: Mon, 27 Nov 2017 12:09:52 +0100 Message-ID: <1511780999-27757-4-git-send-email-claziss@synopsys.com> In-Reply-To: <1511780999-27757-1-git-send-email-claziss@synopsys.com> References: <1511780999-27757-1-git-send-email-claziss@synopsys.com> MIME-Version: 1.0 From: Claudiu Zissulescu The ARC ZOL implementation doesn't allow the last instruction to be a control instruction or part of a delay slot. Thus, we add a note to the last ZOL instruction which will prevent it to finish into a delay slot. 2017-10-20 Claudiu Zissulescu * config/arc/arc.c (hwloop_optimize): Prevent the last ZOL instruction to end into a delay slot. * config/arc/arc.md (cond_delay_insn): Check if the instruction can be placed into a delay slot against reg_note. (in_delay_slot): Likewise. testsuite/ 2017-10-20 Claudiu Zissulescu * gcc.target/arc/loop-3.c: New test. * gcc.target/arc/loop-4.c: Likewise. [FIX][ZOL] fix checking for jumps --- gcc/config/arc/arc.c | 6 ++++++ gcc/config/arc/arc.md | 4 ++++ gcc/testsuite/gcc.target/arc/loop-3.c | 27 +++++++++++++++++++++++++++ gcc/testsuite/gcc.target/arc/loop-4.c | 14 ++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 gcc/testsuite/gcc.target/arc/loop-3.c create mode 100644 gcc/testsuite/gcc.target/arc/loop-4.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 964815a..1479a8d 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -7609,6 +7609,12 @@ hwloop_optimize (hwloop_info loop) loop->loop_no); last_insn = emit_insn_after (gen_nopv (), last_insn); } + + /* SAVE_NOTE is used by haifa scheduler. However, we are after it + and we can use it to indicate the last ZOL instruction cannot be + part of a delay slot. */ + add_reg_note (last_insn, REG_SAVE_NOTE, GEN_INT (2)); + loop->last_insn = last_insn; /* Get the loop iteration register. */ diff --git a/gcc/config/arc/arc.md b/gcc/config/arc/arc.md index 2e0ac52..6239483 100644 --- a/gcc/config/arc/arc.md +++ b/gcc/config/arc/arc.md @@ -472,6 +472,8 @@ (symbol_ref "(arc_hazard (prev_active_insn (insn), insn) + arc_hazard (insn, next_active_insn (insn)))")) (const_string "false") + (match_test "find_reg_note (insn, REG_SAVE_NOTE, GEN_INT (2))") + (const_string "false") (eq_attr "iscompact" "maybe") (const_string "true") ] @@ -499,6 +501,8 @@ (cond [(eq_attr "cond" "!canuse") (const_string "no") (eq_attr "type" "call,branch,uncond_branch,jump,brcc") (const_string "no") + (match_test "find_reg_note (insn, REG_SAVE_NOTE, GEN_INT (2))") + (const_string "no") (eq_attr "length" "2,4") (const_string "yes")] (const_string "no"))) diff --git a/gcc/testsuite/gcc.target/arc/loop-3.c b/gcc/testsuite/gcc.target/arc/loop-3.c new file mode 100644 index 0000000..bf7aec9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-3.c @@ -0,0 +1,27 @@ +/* { dg-do assemble } */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mno-sdata" } * + +/* This example will fail to assemble if the last instruction is a + branch with delay slot. */ +int d; +extern char * fn2 (void); + +void fn1(void) +{ + char *a = fn2(); + for (;;) { + long long b; + int e = 8; + for (; e <= 63; e += 7) { + long c = *a++; + b += c & e; + if (c & 28) + break; + } + d = b; + } +} + +/* { dg-final { scan-assembler "bne_s @.L2" } } */ +/* { dg-final { scan-assembler-not "add.eq" } } */ diff --git a/gcc/testsuite/gcc.target/arc/loop-4.c b/gcc/testsuite/gcc.target/arc/loop-4.c new file mode 100644 index 0000000..99a93a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-4.c @@ -0,0 +1,14 @@ +/* { dg-do assemble } */ +/* { dg-do compile } */ +/* { dg-options "-Os" } */ + + +void fn1(void *p1, int p2, int p3) +{ + char *d = p1; + do + *d++ = p2; + while (--p3); +} + +/* { dg-final { scan-assembler "lp_count" } } */