From patchwork Tue Jan 21 19:17:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 313026 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 E03332C00A5 for ; Wed, 22 Jan 2014 06:17:30 +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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=WgQxw6B0F0QQKfslxcFaeYgO72aXJJaIggK0RnZG37+c3n EloC9tJlRXX4+qnNHnCjzSWS/3yyjy2fDe4bYAo7KSpWOOzXZUYa5WgOGOplHL8L NQv+rZ41Hym6tpcrqDv9isaJ3WcwxcKbX6s9W8DXxOp5vjhJgnygk3TW6UOJg= 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 :message-id:date:from:mime-version:to:subject:content-type; s= default; bh=4dIVBBvV+C/B6DpvS3FDGnQba/s=; b=tcYPiHWENKcsvYHFQTD9 oTtNd34dnphFZgWpqM/MnPjkwSHvEpr/dfLRCsyYI7iF39+GTN0cw3kBvSikLI7f 10Y5uFA6x2P4yxEYBveHG4NPd61XShk1Hb89rXsSAMyibEARfNuyooXXxsaojOv/ 7R/DC/ZbCkwcMGkzU/DwzAY= Received: (qmail 1192 invoked by alias); 21 Jan 2014 19:17:24 -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 1172 invoked by uid 89); 21 Jan 2014 19:17:23 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.3 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 21 Jan 2014 19:17:22 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s0LJHJST022519 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Jan 2014 14:17:20 -0500 Received: from topor.usersys.redhat.com ([10.15.16.142]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s0LJHI1D011649 for ; Tue, 21 Jan 2014 14:17:19 -0500 Message-ID: <52DEC7BE.8050108@redhat.com> Date: Tue, 21 Jan 2014 14:17:18 -0500 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: gcc-patches Subject: patch to fix PR59858 X-IsSubscribed: yes The following patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59858 The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 206897. 2014-01-21 Vladimir Makarov PR rtl-optimization/59858 * gcc.target/arm/pr59858.c: New. 2014-01-21 Vladimir Makarov PR rtl-optimization/59858 * gcc.target/arm/pr59858.c: New. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 206844) +++ lra-constraints.c (working copy) @@ -688,9 +688,10 @@ operands_match_p (rtx x, rtx y, int y_ha /* True if C is a non-empty register class that has too few registers to be safely used as a reload target class. */ -#define SMALL_REGISTER_CLASS_P(C) \ - (reg_class_size [(C)] == 1 \ - || (reg_class_size [(C)] >= 1 && targetm.class_likely_spilled_p (C))) +#define SMALL_REGISTER_CLASS_P(C) \ + (ira_class_hard_regs_num [(C)] == 1 \ + || (ira_class_hard_regs_num [(C)] >= 1 \ + && targetm.class_likely_spilled_p (C))) /* If REG is a reload pseudo, try to make its class satisfying CL. */ static void @@ -2113,17 +2114,25 @@ process_alt_operands (int only_alternati } /* If the operand is dying, has a matching constraint, and satisfies constraints of the matched operand - which failed to satisfy the own constraints, we do - not need to generate a reload insn for this - operand. */ - if (!(this_alternative_matches >= 0 - && !curr_alt_win[this_alternative_matches] - && REG_P (op) - && find_regno_note (curr_insn, REG_DEAD, REGNO (op)) - && (hard_regno[nop] >= 0 - ? in_hard_reg_set_p (this_alternative_set, - mode, hard_regno[nop]) - : in_class_p (op, this_alternative, NULL)))) + which failed to satisfy the own constraints, probably + the reload for this operand will be gone. */ + if (this_alternative_matches >= 0 + && !curr_alt_win[this_alternative_matches] + && REG_P (op) + && find_regno_note (curr_insn, REG_DEAD, REGNO (op)) + && (hard_regno[nop] >= 0 + ? in_hard_reg_set_p (this_alternative_set, + mode, hard_regno[nop]) + : in_class_p (op, this_alternative, NULL))) + { + if (lra_dump_file != NULL) + fprintf + (lra_dump_file, + " %d Dying matched operand reload: reject++\n", + nop); + reject++; + } + else { /* Strict_low_part requires to reload the register not the sub-register. In this case we should Index: testsuite/gcc.target/arm/pr59858.c =================================================================== --- testsuite/gcc.target/arm/pr59858.c (revision 0) +++ testsuite/gcc.target/arm/pr59858.c (working copy) @@ -0,0 +1,162 @@ +/* { dg-do compile } */ +/* { dg-options "-march=armv5te -marm -mthumb-interwork -Wall -Wstrict-prototypes -Wstrict-aliasing -funsigned-char -fno-builtin -fno-asm -msoft-float -std=gnu99 -mlittle-endian -mthumb -fno-stack-protector -Os -g -feliminate-unused-debug-types -funit-at-a-time -fmerge-all-constants -fstrict-aliasing -fno-tree-loop-optimize -fno-tree-dominator-opts -fno-strength-reduce -fPIC -w" } */ + +typedef enum { + REG_ENOSYS = -1, +} reg_errcode_t; +typedef unsigned long int bitset_word_t; +typedef bitset_word_t bitset_t[(256 / (sizeof (bitset_word_t) * 8))]; +typedef bitset_word_t *re_bitset_ptr_t; +typedef const bitset_word_t *re_const_bitset_ptr_t; +typedef struct { + int nelem; + int *elems; +} re_node_set; +typedef enum { + CHARACTER = 1, +} re_token_type_t; +typedef struct { + re_token_type_t type:8; + unsigned int word_char:1; +} re_token_t; +struct re_string_t { + const unsigned char *raw_mbs; + int raw_mbs_idx; + int cur_idx; + unsigned int tip_context; + re_const_bitset_ptr_t word_char; +}; +typedef struct re_string_t re_string_t; +typedef struct re_dfa_t re_dfa_t; +struct re_dfastate_t { + re_node_set nodes; +}; +typedef struct re_dfastate_t re_dfastate_t; +typedef struct { + re_dfastate_t **array; +} state_array_t; +typedef struct { + state_array_t path; +} re_sub_match_last_t; +typedef struct { + int nlasts; + re_sub_match_last_t **lasts; +} re_sub_match_top_t; +typedef struct { + re_string_t input; + const re_dfa_t *dfa; + int nsub_tops; + re_sub_match_top_t **sub_tops; +} re_match_context_t; +struct re_dfa_t { + re_token_t *nodes; + re_bitset_ptr_t sb_char; + int mb_cur_max; + bitset_t word_char; +} bracket_elem_t; +static reg_errcode_t +re_string_reconstruct ( + re_string_t * pstr, + int idx, + int eflags +) +{ + int offset = idx - pstr->raw_mbs_idx; + int c = pstr->raw_mbs[pstr->raw_mbs_idx + offset - 1]; + pstr->tip_context = ((pstr->word_char[c] & ((bitset_word_t) 1)) ? : (c)); +} + +static void match_ctx_clean ( + re_match_context_t * +); +static int check_matching ( +); +static re_dfastate_t *transit_state ( +); +static int build_trtable ( +); +re_search_internal (int eflags +) +{ + reg_errcode_t err; + int incr; + int + match_first, + match_last = -1; + re_match_context_t mctx; + err = re_string_allocate (&mctx.input); + for (;; match_first += incr) + { + err = re_string_reconstruct (&mctx.input, match_first, eflags); + err = re_string_reconstruct (&mctx.input, match_first, eflags); + match_last = check_matching (&mctx, &match_first); + match_ctx_clean (&mctx); + } +} + +check_matching (re_match_context_t * mctx, int *p_match_first +) +{ + int cur_str_idx = ((&mctx->input)->cur_idx); + re_dfastate_t *cur_state; + int next_start_idx = cur_str_idx; + cur_state = transit_state (mctx, cur_state); + *p_match_first += next_start_idx; +} + +static re_dfastate_t * +transit_state ( + re_match_context_t * mctx, + re_dfastate_t * state +) +{ + if (!build_trtable (mctx->dfa, state)) + { + } +} + +build_trtable (const re_dfa_t * dfa, + re_dfastate_t * state +) +{ + int i, + j; + bitset_t accepts; + const re_node_set *cur_nodes = &state->nodes; + for (i = 0; i < cur_nodes->nelem; ++i) + { + re_token_t *node = &dfa->nodes[cur_nodes->elems[i]]; + re_token_type_t type = node->type; + { + if (dfa->mb_cur_max > 1) + bitset_merge (accepts, dfa->sb_char); + { + bitset_word_t any_set = 0; + if (type == CHARACTER && !node->word_char) + any_set |= (accepts[j] &= (dfa->word_char[j] | ~dfa->sb_char[j])); + else + for (j = 0; j < (256 / (sizeof (bitset_word_t) * 8)); ++j) + any_set |= (accepts[j] &= dfa->word_char[j]); + } + } + } +} + +static void +match_ctx_clean ( + re_match_context_t * mctx +) +{ + int st_idx; + for (st_idx = 0; st_idx < mctx->nsub_tops; ++st_idx) + { + int sl_idx; + re_sub_match_top_t *top = mctx->sub_tops[st_idx]; + for (sl_idx = 0; sl_idx < top->nlasts; ++sl_idx) + { + re_sub_match_last_t *last = top->lasts[sl_idx]; + free (last->path.array); + } + } +} +