From patchwork Mon Apr 10 15:05:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 749057 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 3w1tmK0lKXz9sNh for ; Tue, 11 Apr 2017 01:05:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="YU3dDyJi"; 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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=qQn8vl+n80nhWGx29gDYt3Fgewemr25QMX2PPAPazgWwKcJwT9 ZCsn4qZvFSmOPFyT3OZKASg/LN9Ke9cAUxPzsD5qKhfuh1Ru7usLyKdbOvvJkfBb +Ly3w8dMeVwAYtaUs7c0IfPixsZGbFOQ6AdqBCaVSvxn/OR4rLzfR4Vv0= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=CLnBD4SwLOOOsNEUH8dQubKufkQ=; b=YU3dDyJiGMyK0DRjZ/7s kIjXoapb3N+ium9aNhp+2lg192OwflwU8wRXmAMGaGkyTx/EpYZauAJg7+VnENb9 qcZitfZhp+nA67pSlXr+vZcLx97+30KvwS9qf2dJa1rVKD2PyC34daWeHU7dPD0L CcQXjOrsMo+0WupO3NsLnss= Received: (qmail 32135 invoked by alias); 10 Apr 2017 15:05:39 -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 30705 invoked by uid 89); 10 Apr 2017 15:05:38 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=refuse, Major, matthew, Matthew 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; Mon, 10 Apr 2017 15:05:36 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F23D61D35 for ; Mon, 10 Apr 2017 15:05:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F23D61D35 Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=vmakarov@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0F23D61D35 Received: from topor.usersys.redhat.com (unused-10-15-17-214.yyz.redhat.com [10.15.17.214]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9BC959AD2A for ; Mon, 10 Apr 2017 15:05:36 +0000 (UTC) To: gcc-patches From: Vladimir Makarov Subject: One more path to fix PR70478 Message-ID: <930934bd-0341-6607-3d7e-96c34cebbabc@redhat.com> Date: Mon, 10 Apr 2017 11:05:36 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 X-IsSubscribed: yes This is the second try to fix https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70478 The first try patch triggered a latent bug and broke one Fortran testcase on x86-64. The patch was successfully bootstrapped on x86-64 and tested on x86-64, ppc64, and aarch64. Committed as rev. 246808. Index: ChangeLog =================================================================== --- ChangeLog (revision 246807) +++ ChangeLog (working copy) @@ -1,3 +1,12 @@ +2017-04-10 Vladimir Makarov + + PR rtl-optimization/70478 + * lra-constraints.c (curr_small_class_check): New. + (update_and_check_small_class_inputs): New. + (process_alt_operands): Update curr_small_class_check. Disfavor + alternative insn memory operands. Check available regs for small + class operands. + 2017-03-31 Matthew Fortune PR target/80057 Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 246789) +++ lra-constraints.c (working copy) @@ -1852,6 +1852,42 @@ prohibited_class_reg_set_mode_p (enum re (temp, ira_prohibited_class_mode_regs[rclass][mode])); } + +/* Used to check validity info about small class input operands. It + should be incremented at start of processing an insn + alternative. */ +static unsigned int curr_small_class_check = 0; + +/* Update number of used inputs of class OP_CLASS for operand NOP. + Return true if we have more such class operands than the number of + available regs. */ +static bool +update_and_check_small_class_inputs (int nop, enum reg_class op_class) +{ + static unsigned int small_class_check[LIM_REG_CLASSES]; + static int small_class_input_nums[LIM_REG_CLASSES]; + + if (SMALL_REGISTER_CLASS_P (op_class) + /* We are interesting in classes became small because of fixing + some hard regs, e.g. by an user through GCC options. */ + && hard_reg_set_intersect_p (reg_class_contents[op_class], + ira_no_alloc_regs) + && (curr_static_id->operand[nop].type != OP_OUT + || curr_static_id->operand[nop].early_clobber)) + { + if (small_class_check[op_class] == curr_small_class_check) + small_class_input_nums[op_class]++; + else + { + small_class_check[op_class] = curr_small_class_check; + small_class_input_nums[op_class] = 1; + } + if (small_class_input_nums[op_class] > ira_class_hard_regs_num[op_class]) + return true; + } + return false; +} + /* Major function to choose the current insn alternative and what operands should be reloaded and how. If ONLY_ALTERNATIVE is not negative we should consider only this alternative. Return false if @@ -1952,6 +1988,7 @@ process_alt_operands (int only_alternati if (!TEST_BIT (preferred, nalt)) continue; + curr_small_class_check++; overall = losers = addr_losers = 0; static_reject = reject = reload_nregs = reload_sum = 0; for (nop = 0; nop < n_operands; nop++) @@ -2685,6 +2722,21 @@ process_alt_operands (int only_alternati } } + /* When we use memory operand, the insn should read the + value from memory and even if we just wrote a value + into the memory it is costly in comparison with an + insn alternative which does not use memory + (e.g. register or immediate operand). */ + if (no_regs_p && offmemok) + { + if (lra_dump_file != NULL) + fprintf + (lra_dump_file, + " Using memory insn operand %d: reject+=3\n", + nop); + reject += 3; + } + #ifdef SECONDARY_MEMORY_NEEDED /* If reload requires moving value through secondary memory, it will need one more insn at least. */ @@ -2747,6 +2799,14 @@ process_alt_operands (int only_alternati goto fail; } + if (update_and_check_small_class_inputs (nop, this_alternative)) + { + if (lra_dump_file != NULL) + fprintf (lra_dump_file, + " alt=%d, not enough small class regs -- refuse\n", + nalt); + goto fail; + } curr_alt[nop] = this_alternative; COPY_HARD_REG_SET (curr_alt_set[nop], this_alternative_set); curr_alt_win[nop] = this_alternative_win;