From patchwork Tue Sep 11 17:53:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steven Bosscher X-Patchwork-Id: 183161 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 C218B2C0082 for ; Wed, 12 Sep 2012 03:54:11 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1347990853; h=Comment: DomainKey-Signature:Received:Received:Received:Received:Received: MIME-Version:Received:In-Reply-To:References:From:Date: Message-ID:Subject:To:Cc:Content-Type:Mailing-List:Precedence: List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender: Delivered-To; bh=L2JQSZ/YENc9ijuT548FR1F1wh4=; b=hJijNt2lm7tpIeX BdiPEA1dlaHW+FGZ3YOEil+/VCgUpY1CuN3sgUPHlf+ugKa4r5bxb6lHvQJ7pjsi wpVHnrm9HAitdHfAzPPucQdcY4gH8IviIwyIetljcXQ3DmBev8e1B1AvoNTlAsaN i6ulEjG8GMsAvQjhlSjcpZBIL6wE= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Received:MIME-Version:Received:In-Reply-To:References:From:Date:Message-ID:Subject:To:Cc:Content-Type:X-IsSubscribed:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=swBfl4suqI8FBXIpzzRI+IR+6nV7cfUN514ktP5dIe2k3J6hoS6NgsA/EciPgr cxdQCd9JHcU7u9KgPJ10J2TSb8zXX+3J+n+TWymQtTJYX5Hndk62Lqwwe4m38olx 0ToayimbmuDyiaPOUazYuazxlIx8wDttZfIvWikKEgvQ0=; Received: (qmail 24794 invoked by alias); 11 Sep 2012 17:53:57 -0000 Received: (qmail 24781 invoked by uid 22791); 11 Sep 2012 17:53:55 -0000 X-SWARE-Spam-Status: No, hits=-5.0 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, KHOP_RCVD_TRUST, KHOP_THREADED, RCVD_IN_DNSWL_LOW, RCVD_IN_HOSTKARMA_YE X-Spam-Check-By: sourceware.org Received: from mail-lb0-f175.google.com (HELO mail-lb0-f175.google.com) (209.85.217.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 11 Sep 2012 17:53:41 +0000 Received: by lban1 with SMTP id n1so590656lba.20 for ; Tue, 11 Sep 2012 10:53:40 -0700 (PDT) Received: by 10.112.44.228 with SMTP id h4mr6455891lbm.82.1347386020136; Tue, 11 Sep 2012 10:53:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.39.229 with HTTP; Tue, 11 Sep 2012 10:53:15 -0700 (PDT) In-Reply-To: <504F52A4.5010308@redhat.com> References: <504F52A4.5010308@redhat.com> From: Steven Bosscher Date: Tue, 11 Sep 2012 19:53:15 +0200 Message-ID: Subject: Re: [patch] Expand SJLJ exceptions as tablejump/casesi To: Richard Henderson Cc: GCC Patches , Jan Hubicka , Richard Guenther 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 Hello, Thanks for the quick review! On Tue, Sep 11, 2012 at 5:03 PM, Richard Henderson wrote: > On 09/10/2012 04:26 PM, Steven Bosscher wrote: >> + rtx index = force_reg (index_mode, dispatch_index); > > You can't modify the result of force_reg. Use copy_to_{mode_,}reg instead. Done. >> + rtx tmp = expand_simple_binop (index_mode, MINUS, >> + index, CONST1_RTX (index_mode), >> + index, 0, OPTAB_DIRECT); >> + gcc_assert (REG_P (tmp)); >> + if (tmp != index) >> + emit_move_insn (index, tmp); > > This pattern is force_expand_binop. Didn't know about this one :-) > Of course, you don't really need to force index be the same all > the way down the chain. You could just as well use > > index = expand_simple_binop (index_mode, MINUS, index, one, > index, 0, OPTAB_DIRECT); > > and use any new pseudo in the next iteration. Right, I've made the changes to do so. > Otherwise this looks good. I made the following changes: $ interdiff sjlj_tablejump.diff.20120910 sjlj_tablejump.diff and I'm re-testing the updated patch. OK for trunk if it passes? Ciao! Steven diff -u stmt.c stmt.c --- stmt.c (working copy) +++ stmt.c (working copy) @@ -2129,19 +2129,16 @@ This is more efficient than a dispatch table on most machines. The last "index--" is redundant but the code is trivially dead and will be cleaned up by later passes. */ - rtx index = force_reg (index_mode, dispatch_index); + rtx index = copy_to_mode_reg (index_mode, dispatch_index); rtx zero = CONST0_RTX (index_mode); for (int i = 0; i < ncases; i++) { tree elt = VEC_index (tree, dispatch_table, i); rtx lab = label_rtx (CASE_LABEL (elt)); do_jump_if_equal (index_mode, index, zero, lab, 0); - rtx tmp = expand_simple_binop (index_mode, MINUS, - index, CONST1_RTX (index_mode), - index, 0, OPTAB_DIRECT); - gcc_assert (REG_P (tmp)); - if (tmp != index) - emit_move_insn (index, tmp); + force_expand_binop (index_mode, code_to_optab (MINUS), + index, CONST1_RTX (index_mode), + index, 0, OPTAB_DIRECT); } } else