From patchwork Wed Mar 27 17:11:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1067223 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-498504-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="F5BxvIt9"; 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 44Tvfp3xh9z9sRW for ; Thu, 28 Mar 2019 04:11:27 +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=UfEoiRyV70CK7r9Tt9A+eDph1rUMHTRzPDDrajbsyKgYGtMXOg h1F0QfeYIzwTP/sS7Z9PbaL1kPUOKjJhrI3RpAPDMP9fdL60wpvZnoE3EvfKVsOG PthmkOjSrdpi9OBCNXKkBveGJFQ7Ej8DcR/SetoJuwbi4YK+Kxq4rtXcU= 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=oSSU/XELxqiK8N1NuPLnVZYu8nw=; b=F5BxvIt9dU9h8PGYYmiL 2VHc3CDvl17VtxwwYxl/kZ3y+o46GRiVmjOq/fkKYViXSq8yXMgT/jeA3I1yIhWv WyJmbOc4Fu5UGSijGlXqumJ8vksYOD1ONgCjJKi5dY7PR8bncM4HgHgVBfb/2YXl q8qNfhAp3xm/NYppngtQQN4= Received: (qmail 120101 invoked by alias); 27 Mar 2019 17:11:17 -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 120090 invoked by uid 89); 27 Mar 2019 17:11:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-17.3 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*RU:!127.0.0.1!, HX-Spam-Relays-External:!127.0.0.1!, H*MI:10c1, H*M:10c1 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Mar 2019 17:11:15 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=svr-ies-mbx-01.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1h9C53-0005Jo-Ou from Andrew_Stubbs@mentor.com for gcc-patches@gcc.gnu.org; Wed, 27 Mar 2019 10:11:13 -0700 Received: from [127.0.0.1] (137.202.0.90) by svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 27 Mar 2019 17:11:10 +0000 To: "gcc-patches@gcc.gnu.org" From: Andrew Stubbs Subject: [committed gcn] Fix scc clobber in movdi_symbol Message-ID: <5e055469-10c1-f480-8cc3-d9a34b636abf@codesourcery.com> Date: Wed, 27 Mar 2019 17:11:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.1 MIME-Version: 1.0 This patch fixes a bug in which symbol load instructions created by LRA clobbered the SCC register, and therefore caused rare bad code bugs. The patch now saves and restores SCC, if called during LRA. The save and restore instructions are later optimized away if SCC isn't actually live. Tested for amdgcn-unknown-amdhsa with no regressions. Andrew Stubbs Mentor Graphics / CodeSourcery Fix scc clobber in movdi_symbol. 2019-03-27 Andrew Stubbs gcc/ * config/gcn/gcn.md (CC_SAVE_REG): New constant. (movdi): Call gen_movdi_symbol_save_scc. (gen_movdi_symbol_save_scc): New insn and split. diff --git a/gcc/config/gcn/gcn.md b/gcc/config/gcn/gcn.md index 4573a4ce32f..2b805a73c56 100644 --- a/gcc/config/gcn/gcn.md +++ b/gcc/config/gcn/gcn.md @@ -24,6 +24,7 @@ ; Named registers (define_constants [(FIRST_SGPR_REG 0) + (CC_SAVE_REG 22) (LAST_SGPR_REG 101) (FLAT_SCRATCH_REG 102) (FLAT_SCRATCH_LO_REG 102) @@ -403,7 +404,10 @@ && (GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == LABEL_REF)) { - emit_insn (gen_movdi_symbol (operands[0], operands[1])); + if (lra_in_progress) + emit_insn (gen_movdi_symbol_save_scc (operands[0], operands[1])); + else + emit_insn (gen_movdi_symbol (operands[0], operands[1])); DONE; } }) @@ -826,6 +830,19 @@ [(set_attr "type" "mult") (set_attr "length" "32")]) +(define_insn_and_split "movdi_symbol_save_scc" + [(set (match_operand:DI 0 "nonimmediate_operand" "=Sg") + (match_operand:DI 1 "general_operand" "Y")) + (clobber (reg:BI CC_SAVE_REG))] + "GET_CODE (operands[1]) == SYMBOL_REF || GET_CODE (operands[1]) == LABEL_REF + && (lra_in_progress || reload_completed)" + "#" + "reload_completed" + [(set (reg:BI CC_SAVE_REG) (reg:BI SCC_REG)) + (parallel [(set (match_dup 0) (match_dup 1)) + (clobber (reg:BI SCC_REG))]) + (set (reg:BI SCC_REG) (reg:BI CC_SAVE_REG))]) + (define_insn "gcn_indirect_call" [(call (mem (match_operand:DI 0 "register_operand" "Sg")) (match_operand 1 "" ""))