From patchwork Thu Nov 24 20:00:26 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Makarov X-Patchwork-Id: 83990 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp223833qgi; Thu, 24 Nov 2016 12:00:57 -0800 (PST) X-Received: by 10.84.216.20 with SMTP id m20mr8941825pli.126.1480017657021; Thu, 24 Nov 2016 12:00:57 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b126si39569954pgc.125.2016.11.24.12.00.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Nov 2016 12:00:57 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-442593-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-442593-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-442593-patch=linaro.org@gcc.gnu.org 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=Yo1APl1ESaoep7TNC180A/vf0pMK2O2mmVlpTVkttAuXu1rQBI 1YBLzuwrI43NwELP7yW3GsIrZiRV7q9EBy/Cl+eJs4f6F5rHw9ZbxueyDPIxgfmo 0sEdQ3pzHipCFdpqzyZ2B2vtJnKOpfq2bbCe6us0xoYfqA5hQsQEea8H8= 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=rZG41utDhp9DJZdeqGpSQB8qlpY=; b=rC/OIMWoObCy7C+sNHGN kQQY6o48YpldMnL4uUrNsZs2hTLWX1zbNek5XbiVCs3OtRbHofJAAqtXcjX9WQes gh92sZTyeHXDuOOuiygwUSESXdPU+MD7w0YvLK7VExI34jYWznNiaJV7wjHKSMh/ nuZOwmMvN0EwcvIWA4AVOts= Received: (qmail 76862 invoked by alias); 24 Nov 2016 20:00:42 -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 76829 invoked by uid 89); 24 Nov 2016 20:00:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.1 required=5.0 tests=BAYES_00, KAM_ASCII_DIVIDERS, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=10026, get_mode_size, GET_MODE_SIZE 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, 24 Nov 2016 20:00:31 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 312C361BA5 for ; Thu, 24 Nov 2016 20:00:30 +0000 (UTC) Received: from brix.home (ovpn-112-27.phx2.redhat.com [10.3.112.27]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id uAOK0RZp025435 for ; Thu, 24 Nov 2016 15:00:28 -0500 To: "gcc-patches@gcc.gnu.org" From: Vladimir N Makarov Subject: Patch to fix PR77541 Message-ID: <3d0f1f7b-3ab1-cd3e-8af9-619cfa2e89ed@redhat.com> Date: Thu, 24 Nov 2016 15:00:26 -0500 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 The patch in the attachment fixes https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77541 The patch was successfully tested and bootstrapped on x86-64. Committed as rev. 242848 Index: ChangeLog =================================================================== --- ChangeLog (revision 242713) +++ ChangeLog (working copy) @@ -1,3 +1,11 @@ +2016-11-24 Vladimir Makarov + + PR rtl-optimization/77541 + * lra-constraints.c (struct input_reload): Add field match_p. + (get_reload_reg): Check modes of input reloads to generate unique + value reload pseudo. + (match_reload): Add input reload pseudo for the current insn. + 2016-11-22 Alexander Monakov * internal-fn.c (expand_GOMP_SIMT_LANE): New. Index: lra-constraints.c =================================================================== --- lra-constraints.c (revision 242713) +++ lra-constraints.c (working copy) @@ -529,6 +529,8 @@ init_curr_operand_mode (void) /* Structure describes input reload of the current insns. */ struct input_reload { + /* True for input reload of matched operands. */ + bool match_p; /* Reloaded value. */ rtx input; /* Reload pseudo used. */ @@ -563,6 +565,7 @@ get_reload_reg (enum op_type type, machi { int i, regno; enum reg_class new_class; + bool unique_p = false; if (type == OP_OUT) { @@ -574,39 +577,53 @@ get_reload_reg (enum op_type type, machi e.g. volatile memory. */ if (! side_effects_p (original)) for (i = 0; i < curr_insn_input_reloads_num; i++) - if (rtx_equal_p (curr_insn_input_reloads[i].input, original) - && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class)) - { - rtx reg = curr_insn_input_reloads[i].reg; - regno = REGNO (reg); - /* If input is equal to original and both are VOIDmode, - GET_MODE (reg) might be still different from mode. - Ensure we don't return *result_reg with wrong mode. */ - if (GET_MODE (reg) != mode) - { - if (in_subreg_p) - continue; - if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode)) - continue; - reg = lowpart_subreg (mode, reg, GET_MODE (reg)); - if (reg == NULL_RTX || GET_CODE (reg) != SUBREG) - continue; - } - *result_reg = reg; - if (lra_dump_file != NULL) - { - fprintf (lra_dump_file, " Reuse r%d for reload ", regno); - dump_value_slim (lra_dump_file, original, 1); - } - if (new_class != lra_get_allocno_class (regno)) - lra_change_class (regno, new_class, ", change to", false); - if (lra_dump_file != NULL) - fprintf (lra_dump_file, "\n"); - return false; - } - *result_reg = lra_create_new_reg (mode, original, rclass, title); + { + if (! curr_insn_input_reloads[i].match_p + && rtx_equal_p (curr_insn_input_reloads[i].input, original) + && in_class_p (curr_insn_input_reloads[i].reg, rclass, &new_class)) + { + rtx reg = curr_insn_input_reloads[i].reg; + regno = REGNO (reg); + /* If input is equal to original and both are VOIDmode, + GET_MODE (reg) might be still different from mode. + Ensure we don't return *result_reg with wrong mode. */ + if (GET_MODE (reg) != mode) + { + if (in_subreg_p) + continue; + if (GET_MODE_SIZE (GET_MODE (reg)) < GET_MODE_SIZE (mode)) + continue; + reg = lowpart_subreg (mode, reg, GET_MODE (reg)); + if (reg == NULL_RTX || GET_CODE (reg) != SUBREG) + continue; + } + *result_reg = reg; + if (lra_dump_file != NULL) + { + fprintf (lra_dump_file, " Reuse r%d for reload ", regno); + dump_value_slim (lra_dump_file, original, 1); + } + if (new_class != lra_get_allocno_class (regno)) + lra_change_class (regno, new_class, ", change to", false); + if (lra_dump_file != NULL) + fprintf (lra_dump_file, "\n"); + return false; + } + /* If we have an input reload with a different mode, make sure it + will get a different hard reg. */ + else if (REG_P (original) + && REG_P (curr_insn_input_reloads[i].input) + && REGNO (original) == REGNO (curr_insn_input_reloads[i].input) + && (GET_MODE (original) + != GET_MODE (curr_insn_input_reloads[i].input))) + unique_p = true; + } + *result_reg = (unique_p + ? lra_create_new_reg_with_unique_value + : lra_create_new_reg) (mode, original, rclass, title); lra_assert (curr_insn_input_reloads_num < LRA_MAX_INSN_RELOADS); curr_insn_input_reloads[curr_insn_input_reloads_num].input = original; + curr_insn_input_reloads[curr_insn_input_reloads_num].match_p = false; curr_insn_input_reloads[curr_insn_input_reloads_num++].reg = *result_reg; return true; } @@ -1002,6 +1019,12 @@ match_reload (signed char out, signed ch lra_emit_move (copy_rtx (new_in_reg), in_rtx); *before = get_insns (); end_sequence (); + /* Add the new pseudo to consider values of subsequent input reload + pseudos. */ + lra_assert (curr_insn_input_reloads_num < LRA_MAX_INSN_RELOADS); + curr_insn_input_reloads[curr_insn_input_reloads_num].input = in_rtx; + curr_insn_input_reloads[curr_insn_input_reloads_num].match_p = true; + curr_insn_input_reloads[curr_insn_input_reloads_num++].reg = new_in_reg; for (i = 0; (in = ins[i]) >= 0; i++) { lra_assert Index: testsuite/ChangeLog =================================================================== --- testsuite/ChangeLog (revision 242713) +++ testsuite/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2016-11-24 Vladimir Makarov + + PR rtl-optimization/77541 + * gcc.target/i386/pr77541.c: New. + 2016-11-22 Jakub Jelinek PR target/78451 Index: testsuite/gcc.target/i386/pr77541.c =================================================================== --- testsuite/gcc.target/i386/pr77541.c (revision 0) +++ testsuite/gcc.target/i386/pr77541.c (working copy) @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target lp64 } */ +/* { dg-options "-O2 -Wno-psabi" } */ + +#define MAGIC 0x0706050403020100 + +typedef unsigned long long u64; +typedef unsigned __int128 v64u128 __attribute__ ((vector_size (64))); + +v64u128 __attribute__ ((noinline, noclone)) +foo (u64 x1, u64 x2, u64 x3, u64 x4, v64u128 x5) +{ + (void)x1, (void)x2; + x4 >>= x4 & 63; + return x3 + x4 + x5; +} + +int +main () +{ + v64u128 x = foo (0, 0, 0, MAGIC, (v64u128) {}); + if (x[0] != MAGIC || x[1] != MAGIC || x[2] != MAGIC || x[3] != MAGIC) + __builtin_abort(); + return 0; +}