From patchwork Sun Aug 3 14:02: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: 376027 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 E642214009B for ; Mon, 4 Aug 2014 00:03:00 +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=TZdG5RD3XVY8iVRfWv694LF+zTuTT 95mFRbVMhBwm7GREcSm+h8B927jvh76QufUwrDrriiCZzI8v2FBJL1roj/VjaVD0 wg05lt2WZGKL4WeItOYiVJX9qlP4/tOoYhF11gv4GA6vgYgAeQACW+YdZ5866nov op9PFneEwZ6FS0= 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=Ae81BvPqgomrjg8YiqXdpU5Dm90=; b=gbj UDYyXlV2nUAPLm+jRTTMKqzQUr4PU9PmvQouHI7fqZsAVwOZqvH3l8Ys6Ou5WAxX OxszbwVRoSwrUMz8enwLsro80rck7cOcWsk7fDmC48GncyTFdHTqNGVvCqafy4ei Pg6M0LHZg2KbyxV51Sy33LTo6oED9/J9q1sD8m7A= Received: (qmail 30804 invoked by alias); 3 Aug 2014 14:02:54 -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 30790 invoked by uid 89); 3 Aug 2014 14:02:53 -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-we0-f179.google.com Received: from mail-we0-f179.google.com (HELO mail-we0-f179.google.com) (74.125.82.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sun, 03 Aug 2014 14:02:51 +0000 Received: by mail-we0-f179.google.com with SMTP id u57so6556515wes.10 for ; Sun, 03 Aug 2014 07:02:48 -0700 (PDT) X-Received: by 10.180.82.166 with SMTP id j6mr21915753wiy.71.1407074568893; Sun, 03 Aug 2014 07:02:48 -0700 (PDT) Received: from localhost ([95.145.138.172]) by mx.google.com with ESMTPSA id je3sm30224316wic.11.2014.08.03.07.02.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Aug 2014 07:02: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 18/50] dse.c:check_mem_read_use References: <87y4v5d77q.fsf@googlemail.com> Date: Sun, 03 Aug 2014 15:02:47 +0100 In-Reply-To: <87y4v5d77q.fsf@googlemail.com> (Richard Sandiford's message of "Sun, 03 Aug 2014 14:38:01 +0100") Message-ID: <87sildacxk.fsf@googlemail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 gcc/ * dse.c: Include rtl-iter.h. (check_mem_read_rtx): Change void * parameter to real type. Remove return value. (check_mem_read_use): Fix comment. Use FOR_EACH_SUBRTX_PTR instead of for_each_rtx. Don't handle null rtxes. Index: gcc/dse.c =================================================================== --- gcc/dse.c 2014-08-03 11:25:10.142956456 +0100 +++ gcc/dse.c 2014-08-03 11:25:25.192105241 +0100 @@ -54,6 +54,7 @@ Software Foundation; either version 3, o #include "is-a.h" #include "gimple.h" #include "gimple-ssa.h" +#include "rtl-iter.h" /* This file contains three techniques for performing Dead Store Elimination (dse). @@ -2089,15 +2090,13 @@ replace_read (store_info_t store_info, i } } -/* A for_each_rtx callback in which DATA is the bb_info. Check to see - if LOC is a mem and if it is look at the address and kill any - appropriate stores that may be active. */ +/* Check the address of MEM *LOC and kill any appropriate stores that may + be active. */ -static int -check_mem_read_rtx (rtx *loc, void *data) +static void +check_mem_read_rtx (rtx *loc, bb_info_t bb_info) { rtx mem = *loc, mem_addr; - bb_info_t bb_info; insn_info_t insn_info; HOST_WIDE_INT offset = 0; HOST_WIDE_INT width = 0; @@ -2106,10 +2105,6 @@ check_mem_read_rtx (rtx *loc, void *data int group_id; read_info_t read_info; - if (!mem || !MEM_P (mem)) - return 0; - - bb_info = (bb_info_t) data; insn_info = bb_info->last_insn; if ((MEM_ALIAS_SET (mem) == ALIAS_SET_MEMORY_BARRIER) @@ -2119,20 +2114,20 @@ check_mem_read_rtx (rtx *loc, void *data fprintf (dump_file, " adding wild read, volatile or barrier.\n"); add_wild_read (bb_info); insn_info->cannot_delete = true; - return 0; + return; } /* If it is reading readonly mem, then there can be no conflict with another write. */ if (MEM_READONLY_P (mem)) - return 0; + return; if (!canon_address (mem, &spill_alias_set, &group_id, &offset, &base)) { if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, " adding wild read, canon_address failure.\n"); add_wild_read (bb_info); - return 0; + return; } if (GET_MODE (mem) == BLKmode) @@ -2260,7 +2255,7 @@ check_mem_read_rtx (rtx *loc, void *data width) && replace_read (store_info, i_ptr, read_info, insn_info, loc, bb_info->regs_live)) - return 0; + return; /* The bases are the same, just see if the offsets overlap. */ @@ -2327,7 +2322,7 @@ check_mem_read_rtx (rtx *loc, void *data offset - store_info->begin, width) && replace_read (store_info, i_ptr, read_info, insn_info, loc, bb_info->regs_live)) - return 0; + return; if (!store_info->alias_set) remove = canon_true_dependence (store_info->mem, @@ -2351,17 +2346,22 @@ check_mem_read_rtx (rtx *loc, void *data i_ptr = i_ptr->next_local_store; } } - return 0; } -/* A for_each_rtx callback in which DATA points the INSN_INFO for +/* A note_uses callback in which DATA points the INSN_INFO for as check_mem_read_rtx. Nullify the pointer if i_m_r_m_r returns true for any part of *LOC. */ static void check_mem_read_use (rtx *loc, void *data) { - for_each_rtx (loc, check_mem_read_rtx, data); + subrtx_ptr_iterator::array_type array; + FOR_EACH_SUBRTX_PTR (iter, array, loc, NONCONST) + { + rtx *loc = *iter; + if (MEM_P (*loc)) + check_mem_read_rtx (loc, (bb_info_t) data); + } }