From patchwork Tue Dec 10 22:11:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1207317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-515656-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="WjDB+0UP"; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.b="faOQTh/o"; dkim-atps=neutral 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 47XZ6X2fWfz9sSS for ; Wed, 11 Dec 2019 09:12:04 +1100 (AEDT) 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=myY9FA4LcIXaMls4120E7F+g/hQbreAmtRiHyDZzrs0AtDwiUe NlU5EKX2xrhoiOT+1q1e0zH3q5BK/dT3Bbu5mdoLA7My1lcqiJWdLHSSXkgue4JM 9N8U/kYKFc/GqjdoabNmi23l736RIP36TWhkaSmMMIgl0ISdE24zG5qm8= 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=5zYDaBiIP6lDkLkf+mcEQHUl09Y=; b=WjDB+0UPhZukoUGfspRX nVcVgF2mFkp1mWR42jMWAJuiP3wQ0U/piPEYR/sbgs4JUiGBV6WdPuHmpHAc0Xo3 qS0mOCTcwC6FPSoDUqlPh+LQZ5EIN1uSnNV9bGoQHEUoL6MrUox/sVvorlZhLrUt cD3T+H0j3A5BRXlD85kuymA= Received: (qmail 111076 invoked by alias); 10 Dec 2019 22:11:57 -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 111067 invoked by uid 89); 10 Dec 2019 22:11:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-8.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, KAM_SHORT autolearn=ham version=3.3.1 spammy=ira, IRA, achieved, 58027 X-HELO: us-smtp-1.mimecast.com Received: from us-smtp-2.mimecast.com (HELO us-smtp-1.mimecast.com) (205.139.110.61) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Dec 2019 22:11:54 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1576015913; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=fN32XEixUFo+n2nphqxJV24bjwWmuvCghJYiPyEVd0A=; b=faOQTh/ovK+uFCZxDL/KxlRZxO6bBxCP7o8JBE3Bs6LNttO/rLt2N0m1KRvlRyFlTTVdRg BCVTt7OL9EXrdJZiYZ/cQu+KY5fPCuC66YJwHFShrf1T3bZOmrjIL+g4X68KsJh/EDI+8g RvdnkhPm5aKISND2jN3rZLxUaIDay3U= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-18-2fmBua8FOw2f3xOBvbTllg-1; Tue, 10 Dec 2019 17:11:48 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 73234800D4C for ; Tue, 10 Dec 2019 22:11:47 +0000 (UTC) Received: from [10.10.125.162] (ovpn-125-162.rdu2.redhat.com [10.10.125.162]) by smtp.corp.redhat.com (Postfix) with ESMTP id 020945D6AE for ; Tue, 10 Dec 2019 22:11:46 +0000 (UTC) To: "gcc-patches@gcc.gnu.org" From: Vladimir Makarov Subject: patch to fix PR92796 Message-ID: Date: Tue, 10 Dec 2019 17:11:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-IsSubscribed: yes The following patch fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92796 The patch was successfully bootstrapped and tested on x86-64. Committed as r279204 Index: ChangeLog =================================================================== --- ChangeLog (revision 279200) +++ ChangeLog (working copy) @@ -1,3 +1,18 @@ +2019-12-10 Vladimir Makarov + + PR rtl-optimization/92796 + * lra-int.h (lra_risky_transformations_p): Rename to + check_and_force_assignment_correctness_p. + * lra-assigns.c: Ditto. + (lra_assign): Reset check_and_force_assignment_correctness_p. + * lra-constraints.c (lra_risky_transformations_p): Rename to + check_and_force_assignment_correctness_p. + (lra_constraints): Set up check_and_force_assignment_correctness_p + only for the 1st sub-pass. + * lra-eliminations.c (process_insn_for_elimination): Set up + check_and_force_assignment_correctness_p if the insn chnaged its + code. + 2019-12-10 Jakub Jelinek PR rtl-optimization/92882 Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 278608) +++ lra-assigns.c (working copy) @@ -1131,7 +1131,7 @@ static int *sorted_pseudos; /* The constraints pass is allowed to create equivalences between pseudos that make the current allocation "incorrect" (in the sense that pseudos are assigned to hard registers from their own conflict - sets). The global variable lra_risky_transformations_p says + sets). The global variable check_and_force_assignment_correctness_p says whether this might have happened. Process pseudos assigned to hard registers (less frequently used @@ -1152,7 +1152,7 @@ setup_live_pseudos_and_spill_after_risky bitmap_iterator bi; int max_regno = max_reg_num (); - if (! lra_risky_transformations_p) + if (! check_and_force_assignment_correctness_p) { for (i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if (reg_renumber[i] >= 0 && lra_reg_info[i].nrefs > 0) @@ -1690,6 +1690,8 @@ lra_assign (bool &fails_p) internal_error ("maximum number of LRA assignment passes is achieved (%d)", LRA_MAX_ASSIGNMENT_ITERATION_NUMBER); + /* Reset the assignment correctness flag: */ + check_and_force_assignment_correctness_p = false; return no_spills_p; } Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 278608) +++ lra-constraints.c (working copy) @@ -4665,11 +4665,14 @@ loc_equivalence_callback (rtx loc, const /* The current iteration number of this LRA pass. */ int lra_constraint_iter; -/* True if we substituted equiv which needs checking register - allocation correctness because the equivalent value contains - allocatable hard registers or when we restore multi-register - pseudo. */ -bool lra_risky_transformations_p; +/* True if we should during assignment sub-pass check assignment + correctness for all pseudos and spill some of them to correct + conflicts. It can be necessary when we substitute equiv which + needs checking register allocation correctness because the + equivalent value contains allocatable hard registers, or when we + restore multi-register pseudo, or when we change the insn code and + its operand became INOUT operand when it was IN one before. */ +bool check_and_force_assignment_correctness_p; /* Return true if REGNO is referenced in more than one block. */ static bool @@ -4811,14 +4814,14 @@ lra_constraints (bool first_p) changed_p = false; if (pic_offset_table_rtx && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER) - lra_risky_transformations_p = true; - else + check_and_force_assignment_correctness_p = true; + else if (first_p) /* On the first iteration we should check IRA assignment correctness. In rare cases, the assignments can be wrong as early clobbers operands are ignored in IRA or usages of paradoxical sub-registers are not taken into account by IRA. */ - lra_risky_transformations_p = first_p; + check_and_force_assignment_correctness_p = true; new_insn_uid_start = get_max_uid (); new_regno_start = first_p ? lra_constraint_new_regno_start : max_reg_num (); /* Mark used hard regs for target stack size calulations. */ @@ -4994,7 +4997,7 @@ lra_constraints (bool first_p) dump_insn_slim (lra_dump_file, curr_insn); } if (contains_reg_p (x, true, false)) - lra_risky_transformations_p = true; + check_and_force_assignment_correctness_p = true; lra_set_insn_deleted (curr_insn); continue; } @@ -5507,7 +5510,7 @@ need_for_split_p (HARD_REG_SET potential /* Don't split call clobbered hard regs living through calls, otherwise we might have a check problem in the assign sub-pass as in the most cases (exception is a - situation when lra_risky_transformations_p value is + situation when check_and_force_assignment_correctness_p value is true) the assign pass assumes that all pseudos living through calls are assigned to call saved hard regs. */ && (regno >= FIRST_PSEUDO_REGISTER @@ -5799,7 +5802,7 @@ split_reg (bool before_p, int original_r sub-register levels, LRA do this on pseudos level right now and this discrepancy may create allocation conflicts after splitting. */ - lra_risky_transformations_p = true; + check_and_force_assignment_correctness_p = true; if (lra_dump_file != NULL) fprintf (lra_dump_file, " ))))))))))))))))))))))))))))))))))))))))))))))))\n"); @@ -6561,7 +6564,7 @@ inherit_in_ebb (rtx_insn *head, rtx_insn before_p, curr_insn, max_uid)) { if (reg->subreg_p) - lra_risky_transformations_p = true; + check_and_force_assignment_correctness_p = true; change_p = true; /* Invalidate. */ usage_insns[src_regno].check = 0; Index: lra-eliminations.c =================================================================== --- lra-eliminations.c (revision 278608) +++ lra-eliminations.c (working copy) @@ -1311,6 +1311,11 @@ process_insn_for_elimination (rtx_insn * if (icode >= 0 && icode != INSN_CODE (insn)) { + if (INSN_CODE (insn) >= 0) + /* Insn code is changed. It may change its operand type + from IN to INOUT. Inform the subsequent assignment + subpass about this situation. */ + check_and_force_assignment_correctness_p = true; INSN_CODE (insn) = icode; lra_update_insn_recog_data (insn); } Index: lra-int.h =================================================================== --- lra-int.h (revision 278413) +++ lra-int.h (working copy) @@ -337,7 +337,7 @@ extern void lra_init_equiv (void); extern int lra_constraint_offset (int, machine_mode); extern int lra_constraint_iter; -extern bool lra_risky_transformations_p; +extern bool check_and_force_assignment_correctness_p; extern int lra_inheritance_iter; extern int lra_undo_inheritance_iter; extern bool lra_constrain_insn (rtx_insn *); Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 279200) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2019-12-10 Vladimir Makarov + + PR rtl-optimization/92796 + * gcc.target/powerpc/pr92796.c: New test. + 2019-12-10 Jakub Jelinek PR rtl-optimization/92882 Index: testsuite/gcc.target/powerpc/pr92796.c =================================================================== --- testsuite/gcc.target/powerpc/pr92796.c (nonexistent) +++ testsuite/gcc.target/powerpc/pr92796.c (working copy) @@ -0,0 +1,21 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fstack-protector-strong -mcpu=power8" } */ + +typedef union +{ + __ieee128 a; + int b; +} c; + +__ieee128 +d (__ieee128 x) +{ + __ieee128 g; + c h; + h.a = x; + g = h.b & 5; + h.b = g; + if (g) + return x - x; + return h.a; +}