From patchwork Wed Oct 8 16:04:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 397666 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 99FA71400E0 for ; Thu, 9 Oct 2014 03:04:46 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=VnBIQC7s7xblhxhaju1CZzx1OfYqAIjWyi3b7La759MoKBdEZJPQ3 XTqaGP5tiLZnnFDEx+Y3c/nNe/GMi1y+08nnC9ha1R3JiLZeXSoLD9nBXcztosuk kM1YeTtABYn5P+eGf6kh3PVcEYYFAkr1WiTUU9rvWGFVqHMreREH2k= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type:content-transfer-encoding; s=default; bh=xESK/dWV7zQxKXGhyf5kGdpq47U=; b=cLjUiKq/FwqSggwU02vFYsuYTDVL MgKmnSNfTGAZlol88ucsW5cgWk4mpioXC9sNoIVy2EFNOyiG9ta5Ii3vDvK4ToN7 VgsmxOu//9I00BHc6eLa5iR+4wd/jOtZjkqNaWxA7eyKFNj7mqzyZe8RTseXZmiP 6xr1Os0e/GTMlKY= Received: (qmail 3494 invoked by alias); 8 Oct 2014 16:04:39 -0000 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 Received: (qmail 3481 invoked by uid 89); 8 Oct 2014 16:04:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com Received: from service87.mimecast.com (HELO service87.mimecast.com) (91.220.42.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 08 Oct 2014 16:04:36 +0000 Received: from cam-owa1.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Wed, 08 Oct 2014 17:04:34 +0100 Received: from localhost ([10.1.255.212]) by cam-owa1.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Wed, 8 Oct 2014 17:04:31 +0100 From: Richard Sandiford To: Rainer Orth Mail-Followup-To: Rainer Orth , "gcc-patches\@gcc.gnu.org" , richard.sandiford@arm.com Cc: "gcc-patches\@gcc.gnu.org" Subject: Re: RFA: Merge definitions of get_some_local_dynamic_name References: <87bnqxna3y.fsf@googlemail.com> <87ppf6x9d9.fsf@googlemail.com> <87d2b4y6wk.fsf@googlemail.com> <8761fxm5m8.fsf@googlemail.com> <87egukhwmg.fsf@e105548-lin.cambridge.arm.com> Date: Wed, 08 Oct 2014 17:04:31 +0100 In-Reply-To: (Rainer Orth's message of "Wed, 8 Oct 2014 08:50:08 +0100") Message-ID: <8761fuim40.fsf@e105548-lin.cambridge.arm.com> User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 X-MC-Unique: 114100817043401301 Rainer Orth writes: > Hi Richard, > >> Does this work for you? I tested it on x86_64-linux-gnu but obviously >> that's not particularly useful for SEQUENCEs. > > the patch is fine, as tested on both sparc-sun-solaris2.11 and (for good > measure) i386-pc-solaris2.11. OK, great. To recap, the idea is that if PATTERN (insn) is a SEQUENCE: FOR_EACH_SUBRTX (...., insn, x) ... should iterate over the insns in the SEQUENCE (including pattern, notes, jump label, etc.). However: FOR_EACH_SUBRTX (...., PATTERN (insn), x) ... should only iterate over the patterns of the insns in the SEQUENCE, since the user of FOR_EACH_SUBRTX isn't expecting to see things like REG_NOTES (and might not handle them correctly). Also tested on x86_64-linux-gnu. OK to install? Thanks, Richard gcc/ * rtlanal.c (generic_subrtx_iterator ::add_subrtxes_to_queue): Add the parts of an insn in reverse order, with the pattern at the top of the queue. Detect when we're iterating over a SEQUENCE pattern and in that case just consider patterns of subinstructions. Index: gcc/rtlanal.c =================================================================== --- gcc/rtlanal.c 2014-09-25 16:40:44.944406590 +0100 +++ gcc/rtlanal.c 2014-10-07 13:13:57.698132753 +0100 @@ -128,29 +128,58 @@ generic_subrtx_iterator ::add_subrtxe value_type *base, size_t end, rtx_type x) { - const char *format = GET_RTX_FORMAT (GET_CODE (x)); + enum rtx_code code = GET_CODE (x); + const char *format = GET_RTX_FORMAT (code); size_t orig_end = end; - for (int i = 0; format[i]; ++i) - if (format[i] == 'e') - { - value_type subx = T::get_value (x->u.fld[i].rt_rtx); - if (__builtin_expect (end < LOCAL_ELEMS, true)) - base[end++] = subx; - else - base = add_single_to_queue (array, base, end++, subx); - } - else if (format[i] == 'E') - { - int length = GET_NUM_ELEM (x->u.fld[i].rt_rtvec); - rtx *vec = x->u.fld[i].rt_rtvec->elem; - if (__builtin_expect (end + length <= LOCAL_ELEMS, true)) - for (int j = 0; j < length; j++) - base[end++] = T::get_value (vec[j]); - else - for (int j = 0; j < length; j++) - base = add_single_to_queue (array, base, end++, - T::get_value (vec[j])); - } + if (__builtin_expect (INSN_P (x), false)) + { + /* Put the pattern at the top of the queue, since that's what + we're likely to want most. It also allows for the SEQUENCE + code below. */ + for (int i = GET_RTX_LENGTH (GET_CODE (x)) - 1; i >= 0; --i) + if (format[i] == 'e') + { + value_type subx = T::get_value (x->u.fld[i].rt_rtx); + if (__builtin_expect (end < LOCAL_ELEMS, true)) + base[end++] = subx; + else + base = add_single_to_queue (array, base, end++, subx); + } + } + else + for (int i = 0; format[i]; ++i) + if (format[i] == 'e') + { + value_type subx = T::get_value (x->u.fld[i].rt_rtx); + if (__builtin_expect (end < LOCAL_ELEMS, true)) + base[end++] = subx; + else + base = add_single_to_queue (array, base, end++, subx); + } + else if (format[i] == 'E') + { + unsigned int length = GET_NUM_ELEM (x->u.fld[i].rt_rtvec); + rtx *vec = x->u.fld[i].rt_rtvec->elem; + if (__builtin_expect (end + length <= LOCAL_ELEMS, true)) + for (unsigned int j = 0; j < length; j++) + base[end++] = T::get_value (vec[j]); + else + for (unsigned int j = 0; j < length; j++) + base = add_single_to_queue (array, base, end++, + T::get_value (vec[j])); + if (code == SEQUENCE && end == length) + /* If the subrtxes of the sequence fill the entire array then + we know that no other parts of a containing insn are queued. + The caller is therefore iterating over the sequence as a + PATTERN (...), so we also want the patterns of the + subinstructions. */ + for (unsigned int j = 0; j < length; j++) + { + typename T::rtx_type x = T::get_rtx (base[j]); + if (INSN_P (x)) + base[j] = T::get_value (PATTERN (x)); + } + } return end - orig_end; }