From patchwork Fri Sep 1 12:32:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Claudiu Zissulescu X-Patchwork-Id: 808670 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-461279-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="oRyvktPS"; 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 3xkJdG6wkCz9s7c for ; Fri, 1 Sep 2017 22:36:18 +1000 (AEST) 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=ITabox+CWObgSZb7 VqzqBuZ1fvHHWsJ1iPS38Xvs/YGLNqCeu86EGhZDtj/m276g8NCHHpqIuC80LLZH GrtUUxxyIxdfNvuCcw5m+GucWd7t5WfcIkk7i7CADCJpxxxl2zppnwUp3y0kHplO mIy6n7TDjalmd9aIM+Ayv5yti+g= 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=UFTjMF7coq/32of2nCTXPd kXIrg=; b=oRyvktPS/aYUGc2OOhduQh6tVLmKWXJMwNorUgnXmeHIDoIzGXchPg RyuUwMLEtoPrlOy2odzAzVCh+Vc/tCp+6t8ApNzPkItDDbnsAmFDQGoB8j4idHnI /JTg/KQJ11rwqg24A1ocGbSdNqFiTZt75sPYOI9wcJ1vJjdvyJAKs= Received: (qmail 10426 invoked by alias); 1 Sep 2017 12:36:12 -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 10417 invoked by uid 89); 1 Sep 2017 12:36:11 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=H*F:D*synopsys.com, H*r:10.100.24 X-HELO: smtprelay.synopsys.com Received: from us01smtprelay-2.synopsys.com (HELO smtprelay.synopsys.com) (198.182.47.9) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 01 Sep 2017 12:36:10 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id F07CD24E171D; Fri, 1 Sep 2017 05:36:08 -0700 (PDT) Received: from mailhost.synopsys.com (localhost [127.0.0.1]) by mailhost.synopsys.com (Postfix) with ESMTP id D9E6964E; Fri, 1 Sep 2017 05:36:08 -0700 (PDT) Received: from us01wehtc1.internal.synopsys.com (us01wehtc1.internal.synopsys.com [10.12.239.235]) by mailhost.synopsys.com (Postfix) with ESMTP id A5652609; Fri, 1 Sep 2017 05:36:04 -0700 (PDT) Received: from IN01WEHTCB.internal.synopsys.com (10.144.199.106) by us01wehtc1.internal.synopsys.com (10.12.239.231) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 1 Sep 2017 05:35:44 -0700 Received: from IN01WEHTCA.internal.synopsys.com (10.144.199.104) by IN01WEHTCB.internal.synopsys.com (10.144.199.105) with Microsoft SMTP Server (TLS) id 14.3.266.1; Fri, 1 Sep 2017 18:05:41 +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; Fri, 1 Sep 2017 18:05:40 +0530 From: Claudiu Zissulescu To: CC: , , Subject: [PATCH] [ARC][ZOL] Account for empty body loops Date: Fri, 1 Sep 2017 14:32:10 +0200 Message-ID: <1504269130-29760-1-git-send-email-claziss@synopsys.com> In-Reply-To: <20170831190757.GO22260@embecosm.com> References: <20170831190757.GO22260@embecosm.com> MIME-Version: 1.0 From: claziss Hi Andrew, By mistake I've pushed an incoplete ZOL-rework patch, and it missing the attached parts. Please can you check if it is ok? Thank you, Claudiu gcc/ 2017-09-01 Claudiu Zissulescu * config/arc/arc.c (hwloop_optimize): Account for empty body loops. testsuite/ 2017-09-01 Claudiu Zissulescu * gcc.target/arc/loop-1.c: Add test. --- gcc/config/arc/arc.c | 13 +++++++++++-- gcc/testsuite/gcc.target/arc/loop-1.c | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100755 gcc/testsuite/gcc.target/arc/loop-1.c diff --git a/gcc/config/arc/arc.c b/gcc/config/arc/arc.c index 52a9b24..d519063 100644 --- a/gcc/config/arc/arc.c +++ b/gcc/config/arc/arc.c @@ -7240,6 +7240,12 @@ hwloop_optimize (hwloop_info loop) fprintf (dump_file, ";; loop %d too long\n", loop->loop_no); return false; } + else if (!loop->length) + { + if (dump_file) + fprintf (dump_file, ";; loop %d is empty\n", loop->loop_no); + return false; + } /* Check if we use a register or not. */ if (!REG_P (loop->iter_reg)) @@ -7311,8 +7317,11 @@ hwloop_optimize (hwloop_info loop) && INSN_P (last_insn) && (JUMP_P (last_insn) || CALL_P (last_insn) || GET_CODE (PATTERN (last_insn)) == SEQUENCE - || get_attr_type (last_insn) == TYPE_BRCC - || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT)) + /* At this stage we can have (insn (clobber (mem:BLK + (reg)))) instructions, ignore them. */ + || (GET_CODE (PATTERN (last_insn)) != CLOBBER + && (get_attr_type (last_insn) == TYPE_BRCC + || get_attr_type (last_insn) == TYPE_BRCC_NO_DELAY_SLOT)))) { if (loop->length + 2 > ARC_MAX_LOOP_LENGTH) { diff --git a/gcc/testsuite/gcc.target/arc/loop-1.c b/gcc/testsuite/gcc.target/arc/loop-1.c new file mode 100755 index 0000000..274bb46 --- /dev/null +++ b/gcc/testsuite/gcc.target/arc/loop-1.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +/* Check how we handle empty body loops. */ + +int a; +void fn1(void) { + int i; + for (; i < 8; i++) { + double A[a]; + } +}