From patchwork Wed Mar 16 15:01:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chung-Lin Tang X-Patchwork-Id: 87265 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]) by ozlabs.org (Postfix) with SMTP id CF8BFB6FEB for ; Thu, 17 Mar 2011 02:01:35 +1100 (EST) Received: (qmail 9149 invoked by alias); 16 Mar 2011 15:01:31 -0000 Received: (qmail 9140 invoked by uid 22791); 16 Mar 2011 15:01:30 -0000 X-SWARE-Spam-Status: No, hits=-2.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW X-Spam-Check-By: sourceware.org Received: from mail-px0-f176.google.com (HELO mail-px0-f176.google.com) (209.85.212.176) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 16 Mar 2011 15:01:26 +0000 Received: by pxi11 with SMTP id 11so338506pxi.21 for ; Wed, 16 Mar 2011 08:01:24 -0700 (PDT) Received: by 10.142.237.3 with SMTP id k3mr51043wfh.214.1300287684320; Wed, 16 Mar 2011 08:01:24 -0700 (PDT) Received: from [192.168.1.100] ([210.123.94.75]) by mx.google.com with ESMTPS id w11sm1255126wfh.18.2011.03.16.08.01.22 (version=SSLv3 cipher=OTHER); Wed, 16 Mar 2011 08:01:23 -0700 (PDT) Message-ID: <4D80D0B6.5090408@codesourcery.com> Date: Thu, 17 Mar 2011 00:01:10 +0900 From: Chung-Lin Tang User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 MIME-Version: 1.0 To: gcc-patches Subject: [patch] Simplify further in combine 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 Hi, this patch adds slightly more simplification in try_combine(), under -fexpensive-optimizations, by calling subst() to both i2 and i1. Supplied is an ARM testcase where this resulted in one less redundant ZERO_EXTEND insn under ARMv6 and above. Bootstrapped and tested on i686 and x86_64, cross-tested on ARM-Linux using QEMU, all with no regressions. Okay for trunk? Thanks, Chung-Lin 2011-03-16 Chung-Lin Tang * combine.c (try_combine): Do simplification only call of subst() on i2 even when i1 is present. Update comments. testsuite/ * gcc.target/arm/unsigned-extend-1.c: New testcase. Index: combine.c =================================================================== --- combine.c (revision 170996) +++ combine.c (working copy) @@ -3063,7 +3063,7 @@ /* It is possible that the source of I2 or I1 may be performing an unneeded operation, such as a ZERO_EXTEND of something that is known to have the high part zero. Handle that case - by letting subst look at the innermost one of them. + by letting subst look at the inner insns. Another way to do this would be to have a function that tries to simplify a single insn instead of merging two or more @@ -3088,11 +3088,9 @@ subst_low_luid = DF_INSN_LUID (i1); i1src = subst (i1src, pc_rtx, pc_rtx, 0, 0); } - else - { - subst_low_luid = DF_INSN_LUID (i2); - i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0); - } + + subst_low_luid = DF_INSN_LUID (i2); + i2src = subst (i2src, pc_rtx, pc_rtx, 0, 0); } n_occurrences = 0; /* `subst' counts here */ Index: testsuite/gcc.target/arm/unsigned-extend-1.c =================================================================== --- testsuite/gcc.target/arm/unsigned-extend-1.c (revision 0) +++ testsuite/gcc.target/arm/unsigned-extend-1.c (revision 0) @@ -0,0 +1,9 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -march=armv6" } */ + +unsigned char foo (unsigned char c) +{ + return (c >= '0') && (c <= '9'); +} + +/* { dg-final { scan-assembler-not "uxtb" } } */