From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29944 invoked by alias); 27 Oct 2014 02:05:55 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 27773 invoked by uid 89); 27 Oct 2014 02:05:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-la0-f51.google.com Received: from mail-la0-f51.google.com (HELO mail-la0-f51.google.com) (209.85.215.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 27 Oct 2014 02:05:47 +0000 Received: by mail-la0-f51.google.com with SMTP id q1so1853679lam.24 for ; Sun, 26 Oct 2014 19:05:43 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.112.125.106 with SMTP id mp10mr20459198lbb.50.1414375543787; Sun, 26 Oct 2014 19:05:43 -0700 (PDT) Received: by 10.25.213.80 with HTTP; Sun, 26 Oct 2014 19:05:43 -0700 (PDT) In-Reply-To: <000001cff188$ca24cf50$5e6e6df0$@arm.com> References: <000001cff188$ca24cf50$5e6e6df0$@arm.com> Date: Mon, 27 Oct 2014 02:19:00 -0000 Message-ID: Subject: Re: [PATCH, ifcvt] Check size cost in noce_try_store_flag_mask From: Andrew Pinski To: Zhenqiang Chen Cc: GCC Patches Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2014-10/txt/msg02708.txt.bz2 On Sun, Oct 26, 2014 at 6:53 PM, Zhenqiang Chen wrote: > Hi, > > Function noce_try_store_flag_mask converts "if (test) x = 0;" to "x &= > -(test == 0);" > > But from code size view, "x &= -(test == 0);" might have more instructions > than "if (test) x = 0;". The patch checks the cost to determine the > conversion is valuable or not. > > Bootstrap and no make check regression on X86-64. > No make check regression with Cortex-M0 qemu. > For CSiBE, ARM Cortex-m0 result is a little better. A little regression for > MIPS. Roughly no change for PowerPC. > > OK for trunk? > > Thanks! > -Zhenqiang > > ChangeLog: > 2014-10-27 Zhenqiang Chen > > * ifcvt.c (noce_try_store_flag_mask): Check rtx cost. > > testsuite/ChangeLog: > 2014-10-27 Zhenqiang Chen > > * gcc.target/arm/ifcvt-size-check.c: New test. > > diff --git a/gcc/ifcvt.c b/gcc/ifcvt.c > index 949d2b4..3abd518 100644 > --- a/gcc/ifcvt.c > +++ b/gcc/ifcvt.c > @@ -1393,6 +1393,14 @@ noce_try_store_flag_mask (struct noce_if_info > *if_info) > if (!seq) > return FALSE; > > + if (optimize_function_for_size_p (cfun)) > + { > + int old_cost = COSTS_N_INSNS (if_info->branch_cost + 1); > + int new_cost = seq_cost (seq, 0); > + if (new_cost > old_cost) > + return FALSE; > + } Why not do it unconditionally rather than base this on optimize for size? If the costs are incorrect for non optimize for size, we need to fix those. Thanks, Andrew Pinski > + > emit_insn_before_setloc (seq, if_info->jump, > INSN_LOCATION (if_info->insn_a)); > return TRUE; > diff --git a/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c > b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c > new file mode 100644 > index 0000000..43fa16b > --- /dev/null > +++ b/gcc/testsuite/gcc.target/arm/ifcvt-size-check.c > @@ -0,0 +1,13 @@ > +/* { dg-do assemble } */ > +/* { dg-options "-mthumb -Os " } */ > +/* { dg-require-effective-target arm_thumb1_ok } */ > + > +int > +test (unsigned char iov_len, int count, int i) > +{ > + unsigned char bytes = 0; > + if ((unsigned char) ((char) 127 - bytes) < iov_len) > + return 22; > + return 0; > +} > +/* { dg-final { object-size text <= 12 } } */ > > >