From patchwork Thu Jun 27 16:22:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 255107 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 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 747102C0079 for ; Fri, 28 Jun 2013 02:23: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 :message-id:date:from:mime-version:to:subject:content-type; q= dns; s=default; b=WENFzE8ZHPaoZXdjn5xV3IZLFjFofGx6sJohl9n+R9rf69 5Ga4RsBi6WpOOo8MIhHrFH03kO7tt3YKtQerdc3+DJemMgHFbmmNEuzBM39MAmI1 9k1P2nvtl8yQsTPIDdcLUr9Jt5KCPBDZyVYyS5fN1WO6tkeQ4JDmtdXGX2tlA= 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=jODipR/tSLcPDeRBwryEUFluK+s=; b=SKi3NO6ehOl1c9hgf8M/ X6mzOEForBJsnD7yA4xjix19U0ArPqCQC+F++TPQuTPz6dPKy4m3PBj2djC//Ee3 oIsG2G1CgQTTQ8W77qY3KzB9NxvvR96eQUe4NuqNhzGo2UZ0vDpNj1tbkqwQ0O+K qBCRujt31E60QzgD+lUKS/g= Received: (qmail 27562 invoked by alias); 27 Jun 2013 16:22: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 27537 invoked by uid 89); 27 Jun 2013 16:22:49 -0000 X-Spam-SWARE-Status: No, score=-7.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_HOSTKARMA_W, RCVD_IN_HOSTKARMA_WL, RP_MATCHES_RCVD, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.1 Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Thu, 27 Jun 2013 16:22:48 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r5RGMkqf002222 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 27 Jun 2013 12:22:47 -0400 Received: from topor.usersys.redhat.com ([10.15.16.142]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r5RGMkwS019107 for ; Thu, 27 Jun 2013 12:22:46 -0400 Message-ID: <51CC66D6.5060606@redhat.com> Date: Thu, 27 Jun 2013 12:22:46 -0400 From: Vladimir Makarov User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130514 Thunderbird/17.0.6 MIME-Version: 1.0 To: gcc-patches Subject: patch to fix a bug in LRA hard reg splitting X-Virus-Found: No The following patch fixes a LRA bug for some experimental target. Sorry, there is no a test case and the bug can not be reproduced by other people until the target is made public. The patch was successfully bootstrapped and tested on x86/x86-64. Committed as rev. 200475. 2013-06-27 Vladimir Makarov * lra-constraints.c (inherit_in_ebb): Process static hard regs too. Process OP_INOUT regs for splitting too. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 200425) +++ lra-constraints.c (working copy) @@ -4762,76 +4762,81 @@ inherit_in_ebb (rtx head, rtx tail) } else if (INSN_P (curr_insn)) { + int iter; int max_uid = get_max_uid (); curr_id = lra_get_insn_recog_data (curr_insn); + curr_static_id = curr_id->insn_static_data; to_inherit_num = 0; /* Process insn definitions. */ - for (reg = curr_id->regs; reg != NULL; reg = reg->next) - if (reg->type != OP_IN - && (dst_regno = reg->regno) < lra_constraint_new_regno_start) - { - if (dst_regno >= FIRST_PSEUDO_REGISTER && reg->type == OP_OUT - && reg_renumber[dst_regno] < 0 && ! reg->subreg_p - && usage_insns[dst_regno].check == curr_usage_insns_check - && (next_usage_insns - = usage_insns[dst_regno].insns) != NULL_RTX) - { - struct lra_insn_reg *r; + for (iter = 0; iter < 2; iter++) + for (reg = iter == 0 ? curr_id->regs : curr_static_id->hard_regs; + reg != NULL; + reg = reg->next) + if (reg->type != OP_IN + && (dst_regno = reg->regno) < lra_constraint_new_regno_start) + { + if (dst_regno >= FIRST_PSEUDO_REGISTER && reg->type == OP_OUT + && reg_renumber[dst_regno] < 0 && ! reg->subreg_p + && usage_insns[dst_regno].check == curr_usage_insns_check + && (next_usage_insns + = usage_insns[dst_regno].insns) != NULL_RTX) + { + struct lra_insn_reg *r; - for (r = curr_id->regs; r != NULL; r = r->next) - if (r->type != OP_OUT && r->regno == dst_regno) - break; - /* Don't do inheritance if the pseudo is also - used in the insn. */ - if (r == NULL) - /* We can not do inheritance right now - because the current insn reg info (chain - regs) can change after that. */ - add_to_inherit (dst_regno, next_usage_insns); - } - /* We can not process one reg twice here because of - usage_insns invalidation. */ - if ((dst_regno < FIRST_PSEUDO_REGISTER - || reg_renumber[dst_regno] >= 0) - && ! reg->subreg_p && reg->type == OP_OUT) - { - HARD_REG_SET s; + for (r = curr_id->regs; r != NULL; r = r->next) + if (r->type != OP_OUT && r->regno == dst_regno) + break; + /* Don't do inheritance if the pseudo is also + used in the insn. */ + if (r == NULL) + /* We can not do inheritance right now + because the current insn reg info (chain + regs) can change after that. */ + add_to_inherit (dst_regno, next_usage_insns); + } + /* We can not process one reg twice here because of + usage_insns invalidation. */ + if ((dst_regno < FIRST_PSEUDO_REGISTER + || reg_renumber[dst_regno] >= 0) + && ! reg->subreg_p && reg->type != OP_IN) + { + HARD_REG_SET s; - if (split_if_necessary (dst_regno, reg->biggest_mode, - potential_reload_hard_regs, - false, curr_insn, max_uid)) - change_p = true; - CLEAR_HARD_REG_SET (s); - if (dst_regno < FIRST_PSEUDO_REGISTER) - add_to_hard_reg_set (&s, reg->biggest_mode, dst_regno); - else - add_to_hard_reg_set (&s, PSEUDO_REGNO_MODE (dst_regno), - reg_renumber[dst_regno]); - AND_COMPL_HARD_REG_SET (live_hard_regs, s); - } - /* We should invalidate potential inheritance or - splitting for the current insn usages to the next - usage insns (see code below) as the output pseudo - prevents this. */ - if ((dst_regno >= FIRST_PSEUDO_REGISTER - && reg_renumber[dst_regno] < 0) - || (reg->type == OP_OUT && ! reg->subreg_p - && (dst_regno < FIRST_PSEUDO_REGISTER - || reg_renumber[dst_regno] >= 0))) - { - /* Invalidate and mark definitions. */ - if (dst_regno >= FIRST_PSEUDO_REGISTER) - usage_insns[dst_regno].check = -(int) INSN_UID (curr_insn); - else - { - nregs = hard_regno_nregs[dst_regno][reg->biggest_mode]; - for (i = 0; i < nregs; i++) - usage_insns[dst_regno + i].check - = -(int) INSN_UID (curr_insn); - } - } - } + if (split_if_necessary (dst_regno, reg->biggest_mode, + potential_reload_hard_regs, + false, curr_insn, max_uid)) + change_p = true; + CLEAR_HARD_REG_SET (s); + if (dst_regno < FIRST_PSEUDO_REGISTER) + add_to_hard_reg_set (&s, reg->biggest_mode, dst_regno); + else + add_to_hard_reg_set (&s, PSEUDO_REGNO_MODE (dst_regno), + reg_renumber[dst_regno]); + AND_COMPL_HARD_REG_SET (live_hard_regs, s); + } + /* We should invalidate potential inheritance or + splitting for the current insn usages to the next + usage insns (see code below) as the output pseudo + prevents this. */ + if ((dst_regno >= FIRST_PSEUDO_REGISTER + && reg_renumber[dst_regno] < 0) + || (reg->type == OP_OUT && ! reg->subreg_p + && (dst_regno < FIRST_PSEUDO_REGISTER + || reg_renumber[dst_regno] >= 0))) + { + /* Invalidate and mark definitions. */ + if (dst_regno >= FIRST_PSEUDO_REGISTER) + usage_insns[dst_regno].check = -(int) INSN_UID (curr_insn); + else + { + nregs = hard_regno_nregs[dst_regno][reg->biggest_mode]; + for (i = 0; i < nregs; i++) + usage_insns[dst_regno + i].check + = -(int) INSN_UID (curr_insn); + } + } + } if (! JUMP_P (curr_insn)) for (i = 0; i < to_inherit_num; i++) if (inherit_reload_reg (true, to_inherit[i].regno, @@ -4876,59 +4881,62 @@ inherit_in_ebb (rtx head, rtx tail) } to_inherit_num = 0; /* Process insn usages. */ - for (reg = curr_id->regs; reg != NULL; reg = reg->next) - if ((reg->type != OP_OUT - || (reg->type == OP_OUT && reg->subreg_p)) - && (src_regno = reg->regno) < lra_constraint_new_regno_start) - { - if (src_regno >= FIRST_PSEUDO_REGISTER - && reg_renumber[src_regno] < 0 && reg->type == OP_IN) - { - if (usage_insns[src_regno].check == curr_usage_insns_check - && (next_usage_insns - = usage_insns[src_regno].insns) != NULL_RTX - && NONDEBUG_INSN_P (curr_insn)) - add_to_inherit (src_regno, next_usage_insns); - else if (usage_insns[src_regno].check - != -(int) INSN_UID (curr_insn)) - /* Add usages but only if the reg is not set up - in the same insn. */ - add_next_usage_insn (src_regno, curr_insn, reloads_num); - } - else if (src_regno < FIRST_PSEUDO_REGISTER - || reg_renumber[src_regno] >= 0) - { - bool before_p; - rtx use_insn = curr_insn; + for (iter = 0; iter < 2; iter++) + for (reg = iter == 0 ? curr_id->regs : curr_static_id->hard_regs; + reg != NULL; + reg = reg->next) + if ((reg->type != OP_OUT + || (reg->type == OP_OUT && reg->subreg_p)) + && (src_regno = reg->regno) < lra_constraint_new_regno_start) + { + if (src_regno >= FIRST_PSEUDO_REGISTER + && reg_renumber[src_regno] < 0 && reg->type == OP_IN) + { + if (usage_insns[src_regno].check == curr_usage_insns_check + && (next_usage_insns + = usage_insns[src_regno].insns) != NULL_RTX + && NONDEBUG_INSN_P (curr_insn)) + add_to_inherit (src_regno, next_usage_insns); + else if (usage_insns[src_regno].check + != -(int) INSN_UID (curr_insn)) + /* Add usages but only if the reg is not set up + in the same insn. */ + add_next_usage_insn (src_regno, curr_insn, reloads_num); + } + else if (src_regno < FIRST_PSEUDO_REGISTER + || reg_renumber[src_regno] >= 0) + { + bool before_p; + rtx use_insn = curr_insn; - before_p = (JUMP_P (curr_insn) - || (CALL_P (curr_insn) && reg->type == OP_IN)); - if (NONDEBUG_INSN_P (curr_insn) - && split_if_necessary (src_regno, reg->biggest_mode, - potential_reload_hard_regs, - before_p, curr_insn, max_uid)) - { - if (reg->subreg_p) - lra_risky_transformations_p = true; - change_p = true; - /* Invalidate. */ - usage_insns[src_regno].check = 0; - if (before_p) - use_insn = PREV_INSN (curr_insn); - } - if (NONDEBUG_INSN_P (curr_insn)) - { - if (src_regno < FIRST_PSEUDO_REGISTER) - add_to_hard_reg_set (&live_hard_regs, - reg->biggest_mode, src_regno); - else - add_to_hard_reg_set (&live_hard_regs, - PSEUDO_REGNO_MODE (src_regno), - reg_renumber[src_regno]); - } - add_next_usage_insn (src_regno, use_insn, reloads_num); - } - } + before_p = (JUMP_P (curr_insn) + || (CALL_P (curr_insn) && reg->type == OP_IN)); + if (NONDEBUG_INSN_P (curr_insn) + && split_if_necessary (src_regno, reg->biggest_mode, + potential_reload_hard_regs, + before_p, curr_insn, max_uid)) + { + if (reg->subreg_p) + lra_risky_transformations_p = true; + change_p = true; + /* Invalidate. */ + usage_insns[src_regno].check = 0; + if (before_p) + use_insn = PREV_INSN (curr_insn); + } + if (NONDEBUG_INSN_P (curr_insn)) + { + if (src_regno < FIRST_PSEUDO_REGISTER) + add_to_hard_reg_set (&live_hard_regs, + reg->biggest_mode, src_regno); + else + add_to_hard_reg_set (&live_hard_regs, + PSEUDO_REGNO_MODE (src_regno), + reg_renumber[src_regno]); + } + add_next_usage_insn (src_regno, use_insn, reloads_num); + } + } for (i = 0; i < to_inherit_num; i++) { src_regno = to_inherit[i].regno;