From patchwork Thu Oct 28 19:19:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 69488 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 51550B7043 for ; Fri, 29 Oct 2010 06:19:46 +1100 (EST) Received: (qmail 16703 invoked by alias); 28 Oct 2010 19:19:44 -0000 Received: (qmail 16695 invoked by uid 22791); 28 Oct 2010 19:19:43 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_FW X-Spam-Check-By: sourceware.org Received: from mail-yx0-f175.google.com (HELO mail-yx0-f175.google.com) (209.85.213.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 28 Oct 2010 19:19:37 +0000 Received: by yxe42 with SMTP id 42so1608766yxe.20 for ; Thu, 28 Oct 2010 12:19:35 -0700 (PDT) MIME-Version: 1.0 Received: by 10.42.215.66 with SMTP id hd2mr8826232icb.323.1288293575124; Thu, 28 Oct 2010 12:19:35 -0700 (PDT) Received: by 10.220.170.135 with HTTP; Thu, 28 Oct 2010 12:19:34 -0700 (PDT) In-Reply-To: References: <4CBC698B.3080204@codesourcery.com> Date: Thu, 28 Oct 2010 12:19:34 -0700 Message-ID: Subject: Re: new sign/zero extension elimination pass From: Andrew Pinski To: Tom de Vries Cc: gcc-patches@gcc.gnu.org, Bernd Schmidt X-IsSubscribed: yes 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 On Thu, Oct 28, 2010 at 12:03 PM, Andrew Pinski wrote: > On Mon, Oct 18, 2010 at 8:36 AM, Tom de Vries wrote: >> I created a new sign/zero extension elimination pass. >> >> The motivating example for this pass is: > > In the above case fwprop could do the majority of the work.  In fact > it simplifies the (subreg (zero_extend (subreg))) into (subreg) but > does not replace it.  I think you could extend fwprop to the correct > thing. Something like the attached patch. I have not bootstrap/tested it yet but it works for your simple example. This allows us not to add another pass. Thanks, Andrew Pinski Index: fwprop.c =================================================================== --- fwprop.c (revision 166031) +++ fwprop.c (working copy) @@ -543,8 +543,14 @@ propagate_rtx_1 (rtx *px, rtx old_rtx, r valid_ops &= propagate_rtx_1 (&op0, old_rtx, new_rtx, flags); if (op0 == XEXP (x, 0)) return true; - tem = simplify_gen_subreg (mode, op0, GET_MODE (SUBREG_REG (x)), - SUBREG_BYTE (x)); + tem = simplify_subreg (mode, op0, GET_MODE (SUBREG_REG (x)), + SUBREG_BYTE (x)); + if (!tem) + return false; + else if (GET_CODE (tem) == SUBREG && REG_P (SUBREG_REG (tem))) + valid_ops = true; + else if (REG_P (tem)) + valid_ops = true; } break;