From patchwork Wed May 27 10:25:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kyrill Tkachov X-Patchwork-Id: 477049 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 C551E14018C for ; Wed, 27 May 2015 20:25:54 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=RhETBHIW; 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=default; b=ZVKFjfH+Zi5cvnnjg slDHXTBYrTEo27c6KuNJvDAk5xAW9mBQha8kt2oCFQ4JT5VMupj9b9b+1vQIGK3H l2qe97BSRoj7NIBgpEQ8hB7cqnLMpyyy705XnAha2W6Rt3YbpL2nkiWGrWkut3dX bIyFQO4u6O18ZJlJiuNCWq2JSU= 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 :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=default; bh=rpl+wfe48sbdYpuzJI4EACH v5Jc=; b=RhETBHIWmljLR2mBrzsmdbIZiSJuOKJPVO1jf1Cx4QDV1P8lvPWK1+X FqFQwMgdKPA0jN7IxX25MrS0afRw0ergyV6Y4zXkk73bhNlgyMe0Lr5zsnz9nDnq 9rdfZrOojDu66bF8W1vIHIjNVZbxT4MOb2pobuYK3USs3KwcZxUE= Received: (qmail 79016 invoked by alias); 27 May 2015 10:25:47 -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 79003 invoked by uid 89); 27 May 2015 10:25:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.2 required=5.0 tests=AWL, BAYES_05, KAM_LAZY_DOMAIN_SECURITY, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: foss.arm.com Received: from foss.arm.com (HELO foss.arm.com) (217.140.101.70) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 May 2015 10:25:45 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 9667028; Wed, 27 May 2015 03:25:34 -0700 (PDT) Received: from [10.2.207.50] (e100706-lin.cambridge.arm.com [10.2.207.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D758C3F21B; Wed, 27 May 2015 03:25:42 -0700 (PDT) Message-ID: <55659BA5.5010709@foss.arm.com> Date: Wed, 27 May 2015 11:25:41 +0100 From: Kyrill Tkachov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: GCC Patches CC: Ramana Radhakrishnan , Richard Earnshaw Subject: Re: [PATCH][ARM] Restrict MAX_CONDITIONAL_EXECUTE when -mrestrict-it is in place References: <5559BE41.8040909@foss.arm.com> In-Reply-To: <5559BE41.8040909@foss.arm.com> Ping. Here is the rebased (and retested) patch after Christian's series. Thanks, Kyrill On 18/05/15 11:26, Kyrill Tkachov wrote: > Hi all, > > When using the short Thumb2 IT blocks we want to also restrict ifcvt so that it will not end up generating a number of back-to-back cond_execs > that will later end up being back to back single-instruction IT blocks. Branching over them should be a better choice. > > This patch implements that by setting max_insns_skipped to 1 when arm_restrict_it. > > With this patch, I've seen GCC replace a number of sequences in places like SPEC2006 from: > it eq > moveq r1, r5 > it ne > movne r1, r10 > it eq > moveq r8, r4 > > to a branch over them. > > Bootstrapped and tested on arm. > Ok for trunk? > > Thanks, > Kyrill > > 2015-05-18 Kyrylo Tkachov > > * config/arm/arm.c (arm_option_params_internal): When optimising > for speed set max_insns_skipped when arm_restrict_it. > > 2015-05-18 Kyrylo Tkachov > > * gcc.target/arm/short-it-ifcvt-1.c: New test. > * gcc.target/arm/short-it-ifcvt-2.c: Likewise. commit 2e5bb6e122e96189af1774a4fa451ad7e9b44d3d Author: Kyrylo Tkachov Date: Thu May 14 12:08:14 2015 +0100 [ARM] Restrict MAX_CONDITIONAL_EXECUTE when -mrestrict-it is in place diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index a4eeba3..638d659 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -2788,7 +2788,10 @@ arm_option_params_internal (struct gcc_options *opts) max_insns_skipped = opts->x_arm_restrict_it ? 1 : 4; } else - max_insns_skipped = current_tune->max_insns_skipped; + /* When -mrestrict-it is in use tone down the if-conversion. */ + max_insns_skipped + = (TARGET_THUMB2_P (opts->x_target_flags) && opts->x_arm_restrict_it) + ? 1 : current_tune->max_insns_skipped; } /* Reset options between modes that the user has specified. */ diff --git a/gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c new file mode 100644 index 0000000..f3d29b7 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-1.c @@ -0,0 +1,23 @@ +/* Test that ifcvt is not being too aggressive when -mrestrict-it. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mrestrict-it" } */ +/* { dg-require-effective-target arm_thumb2_ok } */ + +int +f1(int x, int y, int z) +{ + if (x > 100) + { + x++; + z = -z; + } + else + { + x = -x; + y = -y; + z = 1; + } + return x + y + z; +} + +/* { dg-final { scan-assembler "b(gt|le)" } } */ diff --git a/gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c new file mode 100644 index 0000000..9ac8153 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/short-it-ifcvt-2.c @@ -0,0 +1,21 @@ +/* Test that ifcvt is not being too aggressive when -mrestrict-it. */ +/* { dg-do compile } */ +/* { dg-options "-O2 -mrestrict-it" } */ +/* { dg-require-effective-target arm_thumb2_ok } */ + +int +f1(int x, int y, int z) +{ + if (x > 100) + { + x++; + z = -z; + } + else + { + x = -x; + y = -y; + } + return x + y + z; +} +/* { dg-final { scan-assembler "b(gt|le)" } } */