From patchwork Thu Jan 10 21:04:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 1023223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-493805-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (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="RfzkJpJu"; 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 43bJRF2bjhz9s2P for ; Fri, 11 Jan 2019 08:04:55 +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:from :subject:to:message-id:date:mime-version:content-type; q=dns; s= default; b=I52GwZB6XSwR3iPH3fFxFfotbOn1BPqHV6jPYCAFUdPCLEQEyBu00 9qTzz1K6Lac9kF6BALkmeyNx/paHDiikzDxoXUW28mXTpMMtXMJKf/eThuviXHSv O++FzERwy40VRGhvD/qcZYXSoXIMH5gam4ocLsIpYh8YhL2Oolftv4= 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 :subject:to:message-id:date:mime-version:content-type; s= default; bh=DM17Jm67NeAOjPe++0htJMOmpBY=; b=RfzkJpJunIt49MM2JACY /A6V/lloaQeOlGCdy3N9kOhkWDBBN8Y+fLDvpBzLA6I4E/zKyteAq7PI9mfKoOoA jOzm/UwypWbHuy2x8yKvbr6j+oMKE4nyga03lyE0CIuFYvPV2qJa5uj/0s6PNOem GGUBKJrYhyQ+5BM+Q0y9jBk= Received: (qmail 2122 invoked by alias); 10 Jan 2019 21:04:48 -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 2112 invoked by uid 89); 10 Jan 2019 21:04:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.6 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, KAM_NUMSUBJECT, KAM_SHORT, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=y5 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; Thu, 10 Jan 2019 21:04:46 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D808480F9F for ; Thu, 10 Jan 2019 21:04:44 +0000 (UTC) Received: from tobol.usersys.redhat.com (unused-10-15-17-174.yyz.redhat.com [10.15.17.174]) by smtp.corp.redhat.com (Postfix) with ESMTP id 968C660C67 for ; Thu, 10 Jan 2019 21:04:44 +0000 (UTC) From: Vladimir Makarov Subject: patch to fix PR87305 To: gcc-patches Message-ID: <89b612f6-f30a-6abc-1ee6-3b3810117609@redhat.com> Date: Thu, 10 Jan 2019 16:04:44 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.1 MIME-Version: 1.0 X-IsSubscribed: yes The following patch fixes   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87305 The patch was bootstrapped and tested on x86-64 and ppc64 (be). Committed as rev. 267823. Index: ChangeLog =================================================================== --- ChangeLog (revision 267822) +++ ChangeLog (working copy) @@ -1,3 +1,12 @@ +2019-01-10 Vladimir Makarov + + PR rtl-optimization/87305 + * lra-assigns.c + (setup_live_pseudos_and_spill_after_risky_transforms): Check + allocation for big endian pseudos used as paradoxical subregs and + spill them if it is wrong. + * lra-constraints.c (lra_constraints): Add a comment. + 2019-01-10 Richard Biener PR tree-optimization/88792 Index: lra-assigns.c =================================================================== --- lra-assigns.c (revision 267822) +++ lra-assigns.c (working copy) @@ -1146,12 +1146,12 @@ static void setup_live_pseudos_and_spill_after_risky_transforms (bitmap spilled_pseudo_bitmap) { - int p, i, j, n, regno, hard_regno; + int p, i, j, n, regno, hard_regno, biggest_nregs, nregs_diff; unsigned int k, conflict_regno; poly_int64 offset; int val; HARD_REG_SET conflict_set; - machine_mode mode; + machine_mode mode, biggest_mode; lra_live_range_t r; bitmap_iterator bi; int max_regno = max_reg_num (); @@ -1166,8 +1166,26 @@ setup_live_pseudos_and_spill_after_risky for (n = 0, i = FIRST_PSEUDO_REGISTER; i < max_regno; i++) if ((pic_offset_table_rtx == NULL_RTX || i != (int) REGNO (pic_offset_table_rtx)) - && reg_renumber[i] >= 0 && lra_reg_info[i].nrefs > 0) - sorted_pseudos[n++] = i; + && (hard_regno = reg_renumber[i]) >= 0 && lra_reg_info[i].nrefs > 0) + { + biggest_mode = lra_reg_info[i].biggest_mode; + biggest_nregs = hard_regno_nregs (hard_regno, biggest_mode); + nregs_diff = (biggest_nregs + - hard_regno_nregs (hard_regno, PSEUDO_REGNO_MODE (i))); + enum reg_class rclass = lra_get_allocno_class (i); + + if (WORDS_BIG_ENDIAN + && (hard_regno - nregs_diff < 0 + || !TEST_HARD_REG_BIT (reg_class_contents[rclass], + hard_regno - nregs_diff))) + { + /* Hard registers of paradoxical sub-registers are out of + range of pseudo register class. Spill the pseudo. */ + reg_renumber[i] = -1; + continue; + } + sorted_pseudos[n++] = i; + } qsort (sorted_pseudos, n, sizeof (int), pseudo_compare_func); if (pic_offset_table_rtx != NULL_RTX && (regno = REGNO (pic_offset_table_rtx)) >= FIRST_PSEUDO_REGISTER @@ -1206,10 +1224,11 @@ setup_live_pseudos_and_spill_after_risky || hard_regno != reg_renumber[conflict_regno]) { int conflict_hard_regno = reg_renumber[conflict_regno]; - machine_mode biggest_mode = lra_reg_info[conflict_regno].biggest_mode; - int biggest_nregs = hard_regno_nregs (conflict_hard_regno, - biggest_mode); - int nregs_diff + + biggest_mode = lra_reg_info[conflict_regno].biggest_mode; + biggest_nregs = hard_regno_nregs (conflict_hard_regno, + biggest_mode); + nregs_diff = (biggest_nregs - hard_regno_nregs (conflict_hard_regno, PSEUDO_REGNO_MODE (conflict_regno))); Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 267822) +++ lra-constraints.c (working copy) @@ -4739,7 +4739,9 @@ lra_constraints (bool first_p) else /* 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. */ + 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; new_insn_uid_start = get_max_uid (); new_regno_start = first_p ? lra_constraint_new_regno_start : max_reg_num (); Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 267822) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2019-01-10 Vladimir Makarov + + PR rtl-optimization/87305 + * gcc.target/aarch64/pr87305.c: New. + 2019-01-10 Richard Biener PR tree-optimization/88792 Index: testsuite/gcc.target/aarch64/pr87305.c =================================================================== --- testsuite/gcc.target/aarch64/pr87305.c (nonexistent) +++ testsuite/gcc.target/aarch64/pr87305.c (working copy) @@ -0,0 +1,38 @@ +/* { dg-do compile } */ +/* { dg-options "-Ofast -mbig-endian -w" } */ + +int cc; + +void +rc (__int128 *oi) +{ + __int128 qz = (__int128)2 << cc; + + if (qz != 0) + { + if (cc != 0) + { + __int128 zp = 1; + + for (;;) + { + unsigned __int128 *ar = &cc; + int y5; + + if (oi != 0) + { + y3: + zp = *oi + *ar; + } + + y5 = (cc + 1) == ((*ar /= *oi) << ((zp >>= 128) / cc)); + qz += !!y5 ? 1 : qz == (*ar ^ zp + 1); + ++*oi; + } + } + else + ++qz; + } + + goto y3; +}