From patchwork Wed Apr 20 06:22:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tbsaunde+gcc@tbsaunde.org X-Patchwork-Id: 612495 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 3qqWsW6vTLz9t3Z for ; Wed, 20 Apr 2016 16:18:23 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=l/wczUN7; dkim-atps=neutral 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:date:message-id:in-reply-to:references; q=dns; s= default; b=PTW+qRwMs0Ggp2q25rsDMFIdP4kN8+J9OvMD5S/ViDwDwZdG3lNPY aJHCtPWRmAYLyy6P8UuW8zHBUUb94da03lXkJIjXYvBcqmgCS+7P9J4q7VYVq/1E COSism0XETyQRk6N/LD8tR4GYVKxvv5lTr4hEDzCUVXPc286kDpSXQ= 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:date:message-id:in-reply-to:references; s=default; bh=9JSrkz9jrvwBYcMDXi/omrjL68U=; b=l/wczUN7nrGUiZtvWjCWxIOfjirm gTnf1C3oQSkXPk98UxpdDrz//WjBvAxCY2UAx1VZZA/QTLwf/dXmdRolzGuchGxS QqYx7M8g2KD+Fr7cWPw6wh3SuR/WP8zJBN36oqDYCw5PHfHC832o4JhaH+zmsU49 K0B6jkcyGRHlUg0= Received: (qmail 54305 invoked by alias); 20 Apr 2016 06:18:07 -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 54227 invoked by uid 89); 20 Apr 2016 06:18:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=NULL_RTX, null_rtx, dataflow, fputs X-HELO: paperclip.tbsaunde.org Received: from tbsaunde.org (HELO paperclip.tbsaunde.org) (66.228.47.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 20 Apr 2016 06:17:56 +0000 Received: from localhost.localdomain (unknown [23.233.68.71]) by paperclip.tbsaunde.org (Postfix) with ESMTPSA id 3CABBC06F for ; Wed, 20 Apr 2016 06:17:54 +0000 (UTC) From: tbsaunde+gcc@tbsaunde.org To: gcc-patches@gcc.gnu.org Subject: [PATCH 02/18] make avail_stores a vec Date: Wed, 20 Apr 2016 02:22:06 -0400 Message-Id: <1461133342-10794-3-git-send-email-tbsaunde+gcc@tbsaunde.org> In-Reply-To: <1461133342-10794-1-git-send-email-tbsaunde+gcc@tbsaunde.org> References: <1461133342-10794-1-git-send-email-tbsaunde+gcc@tbsaunde.org> X-IsSubscribed: yes From: Trevor Saunders gcc/ChangeLog: 2016-04-19 Trevor Saunders * print-rtl.c (print_rtx_insn_vec): New function. * print-rtl.h: New prototype. * rtl.h: Likewise. * store-motion.c (struct st_expr): Make avail_stores a vector. (st_expr_entry): Adjust. (free_st_expr_entry): Likewise. (print_store_motion_mems): Likewise. (find_moveable_store): Likewise. (compute_store_table): Likewise. (delete_store): Likewise. (build_store_vectors): Likewise. --- gcc/print-rtl.c | 15 +++++++++++++++ gcc/print-rtl.h | 1 + gcc/rtl.h | 1 + gcc/store-motion.c | 31 +++++++++++++++---------------- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 85d9b8d..cf4922f 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -870,6 +870,21 @@ print_simple_rtl (FILE *outf, const_rtx x) flag_simple = 0; } +void +print_rtx_insn_vec (FILE *file, const vec &vec) +{ + fputc('{', file); + + unsigned int len = vec.length (); + for (unsigned int i = 0; i < len; i++) + { + print_rtl (file, vec[i]); + if (i < (len - 1)) + fputs (", ", file); + } + fputc ('}', file); +} + #ifndef GENERATOR_FILE /* The functions below try to print RTL in a form resembling assembler mnemonics. Because this form is more concise than the "traditional" form diff --git a/gcc/print-rtl.h b/gcc/print-rtl.h index 28b4626..e585a63 100644 --- a/gcc/print-rtl.h +++ b/gcc/print-rtl.h @@ -23,6 +23,7 @@ along with GCC; see the file COPYING3. If not see #ifdef BUFSIZ extern void print_rtl (FILE *, const_rtx); #endif +extern void print_rtx_insn_vec (FILE *file, const vec &vec); extern void dump_value_slim (FILE *, const_rtx, int); extern void dump_insn_slim (FILE *, const rtx_insn *); diff --git a/gcc/rtl.h b/gcc/rtl.h index 8267252..167c090 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3572,6 +3572,7 @@ extern void print_simple_rtl (FILE *, const_rtx); extern int print_rtl_single (FILE *, const_rtx); extern int print_rtl_single_with_indent (FILE *, const_rtx, int); extern void print_inline_rtx (FILE *, const_rtx, int); +extern void print_rtx_insn_vec (FILE *file, const vec &vec); /* In stmt.c */ extern void expand_null_return (void); diff --git a/gcc/store-motion.c b/gcc/store-motion.c index fffdffc..6646065 100644 --- a/gcc/store-motion.c +++ b/gcc/store-motion.c @@ -67,7 +67,7 @@ struct st_expr /* INSN list of stores that are locally anticipatable. */ rtx_insn_list *antic_stores; /* INSN list of stores that are locally available. */ - rtx_insn_list *avail_stores; + vec avail_stores; /* Next in the list. */ struct st_expr * next; /* Store ID in the dataflow bitmaps. */ @@ -148,7 +148,7 @@ st_expr_entry (rtx x) ptr->pattern = x; ptr->pattern_regs = NULL_RTX; ptr->antic_stores = NULL; - ptr->avail_stores = NULL; + ptr->avail_stores.create (0); ptr->reaching_reg = NULL_RTX; ptr->index = 0; ptr->hash_index = hash; @@ -164,7 +164,7 @@ static void free_st_expr_entry (struct st_expr * ptr) { free_INSN_LIST_list (& ptr->antic_stores); - free_INSN_LIST_list (& ptr->avail_stores); + ptr->avail_stores.release (); free (ptr); } @@ -240,10 +240,7 @@ print_store_motion_mems (FILE * file) fprintf (file, "\n AVAIL stores : "); - if (ptr->avail_stores) - print_rtl (file, ptr->avail_stores); - else - fprintf (file, "(nil)"); + print_rtx_insn_vec (file, ptr->avail_stores); fprintf (file, "\n\n"); } @@ -591,11 +588,11 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after) it successfully before; if we failed before, do not bother to check until we reach the insn that caused us to fail. */ check_available = 0; - if (!ptr->avail_stores) + if (ptr->avail_stores.is_empty ()) check_available = 1; else { - rtx_insn *tmp = ptr->avail_stores->insn (); + rtx_insn *tmp = ptr->avail_stores.last (); if (BLOCK_FOR_INSN (tmp) != bb) check_available = 1; } @@ -619,7 +616,7 @@ find_moveable_store (rtx_insn *insn, int *regs_set_before, int *regs_set_after) &LAST_AVAIL_CHECK_FAILURE (ptr)); } if (!check_available) - ptr->avail_stores = alloc_INSN_LIST (insn, ptr->avail_stores); + ptr->avail_stores.safe_push (insn); } /* Find available and anticipatable stores. */ @@ -697,7 +694,7 @@ compute_store_table (void) ptr != NULL; ptr = *prev_next_ptr_ptr) { - if (! ptr->avail_stores) + if ( ptr->avail_stores.is_empty ()) { *prev_next_ptr_ptr = ptr->next; store_motion_mems_table->remove_elt_with_hash (ptr, ptr->hash_index); @@ -981,9 +978,10 @@ delete_store (struct st_expr * expr, basic_block bb) reg = expr->reaching_reg; - for (rtx_insn_list *i = expr->avail_stores; i; i = i->next ()) + unsigned int len = expr->avail_stores.length (); + for (unsigned int i = len - 1; i < len; i--) { - rtx_insn *del = i->insn (); + rtx_insn *del = expr->avail_stores[i]; if (BLOCK_FOR_INSN (del) == bb) { /* We know there is only one since we deleted redundant @@ -1018,9 +1016,10 @@ build_store_vectors (void) for (ptr = first_st_expr (); ptr != NULL; ptr = next_st_expr (ptr)) { - for (st = ptr->avail_stores; st != NULL; st = st->next ()) + unsigned int len = ptr->avail_stores.length (); + for (unsigned int i = len - 1; i < len; i--) { - insn = st->insn (); + insn = ptr->avail_stores[i]; bb = BLOCK_FOR_INSN (insn); /* If we've already seen an available expression in this block, @@ -1032,7 +1031,7 @@ build_store_vectors (void) rtx r = gen_reg_rtx_and_attrs (ptr->pattern); if (dump_file) fprintf (dump_file, "Removing redundant store:\n"); - replace_store_insn (r, st->insn (), bb, ptr); + replace_store_insn (r, insn, bb, ptr); continue; } bitmap_set_bit (st_avloc[bb->index], ptr->index);