From patchwork Sun Aug 3 14:07:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 376031 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 C662614009B for ; Mon, 4 Aug 2014 00:07:59 +1000 (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:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=wJOm1xzWLlM18RKy+SHF0tzz1Uu2g +1CyyaPQuhpHwNItnieJxzB64ko00hMKxPguz9Lb2jP0pMl3cTSZqnKNcJsRMUy7 A06XoZZlBSWh09gwGaviozCDLsfO4liJ5roxEGmw97ioBuDt9W1BiL1wwVbYmQN3 QLR5ddwVzV54D0= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=xSK1J2kl2kzvczWBwyoXtlIWNds=; b=OOK rGkXlj6XkGLqRjpcwVLZVeiTe/25pZ5oitkRs/bn4J7RG7RfadrQMT8wqZiiCbQr 8iyKQbHMEeJFA+ZNmBB0TW/shbbhqotqkUA29KQSfrIg6943e6+LpvMhI6Lby1aD Mnb4ln+h4SJ+ozg+Q/KQzY+4GKvwQUUqrScvCK9w= Received: (qmail 6894 invoked by alias); 3 Aug 2014 14:07:53 -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 6882 invoked by uid 89); 3 Aug 2014 14:07:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-wg0-f45.google.com Received: from mail-wg0-f45.google.com (HELO mail-wg0-f45.google.com) (74.125.82.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 03 Aug 2014 14:07:51 +0000 Received: by mail-wg0-f45.google.com with SMTP id x12so6519094wgg.16 for ; Sun, 03 Aug 2014 07:07:48 -0700 (PDT) X-Received: by 10.180.189.4 with SMTP id ge4mr22626511wic.25.1407074868592; Sun, 03 Aug 2014 07:07:48 -0700 (PDT) Received: from localhost ([95.145.138.172]) by mx.google.com with ESMTPSA id h3sm36055087wjz.48.2014.08.03.07.07.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Aug 2014 07:07:48 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, rdsandiford@googlemail.com Subject: [PATCH 21/50] Faster for_each_rtx-like iterators References: <87y4v5d77q.fsf@googlemail.com> Date: Sun, 03 Aug 2014 15:07:47 +0100 In-Reply-To: <87y4v5d77q.fsf@googlemail.com> (Richard Sandiford's message of "Sun, 03 Aug 2014 14:38:01 +0100") Message-ID: <87fvhdacp8.fsf@googlemail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 The switch statement in the old code seemed overly cautious. It's well established elsewhere that the first operand of an RTX_AUTOINC is the automodified register. If anyone wanted to add a new code for which that wasn't true they should (a) reconsider or (b) go through all RTX_AUTOINCs as a precaution. gcc/ * emit-rtl.c: Include rtl-iter.h. (find_auto_inc): Turn from being a for_each_rtx callback to being a function that examines each subrtx itself. Assume the first operand to an RTX_AUTOINC is the automodified register. (try_split): Update call accordingly. Index: gcc/emit-rtl.c =================================================================== --- gcc/emit-rtl.c 2014-08-03 11:25:10.047955517 +0100 +++ gcc/emit-rtl.c 2014-08-03 11:25:26.062113842 +0100 @@ -58,6 +58,7 @@ Software Foundation; either version 3, o #include "params.h" #include "target.h" #include "builtins.h" +#include "rtl-iter.h" struct target_rtl default_target_rtl; #if SWITCHABLE_TARGET @@ -3485,30 +3486,17 @@ prev_cc0_setter (rtx insn) /* Find a RTX_AUTOINC class rtx which matches DATA. */ static int -find_auto_inc (rtx *xp, void *data) +find_auto_inc (const_rtx x, const_rtx reg) { - rtx x = *xp; - rtx reg = (rtx) data; - - if (GET_RTX_CLASS (GET_CODE (x)) != RTX_AUTOINC) - return 0; - - switch (GET_CODE (x)) + subrtx_iterator::array_type array; + FOR_EACH_SUBRTX (iter, array, x, NONCONST) { - case PRE_DEC: - case PRE_INC: - case POST_DEC: - case POST_INC: - case PRE_MODIFY: - case POST_MODIFY: - if (rtx_equal_p (reg, XEXP (x, 0))) - return 1; - break; - - default: - gcc_unreachable (); + const_rtx x = *iter; + if (GET_RTX_CLASS (GET_CODE (x)) == RTX_AUTOINC + && rtx_equal_p (reg, XEXP (x, 0))) + return true; } - return -1; + return false; } #endif @@ -3695,7 +3683,7 @@ try_split (rtx pat, rtx trial, int last) { rtx reg = XEXP (note, 0); if (!FIND_REG_INC_NOTE (insn, reg) - && for_each_rtx (&PATTERN (insn), find_auto_inc, reg) > 0) + && find_auto_inc (PATTERN (insn), reg)) add_reg_note (insn, REG_INC, reg); } break;