From patchwork Thu Oct 28 19:19:34 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: new sign/zero extension elimination pass Date: Thu, 28 Oct 2010 09:19:34 -0000 From: Andrew Pinski X-Patchwork-Id: 69488 Message-Id: To: Tom de Vries Cc: gcc-patches@gcc.gnu.org, Bernd Schmidt 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;