From patchwork Fri Jan 31 11:20:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Stubbs X-Patchwork-Id: 1231850 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-518623-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.a=rsa-sha1 header.s=default header.b=yxyb7uTJ; 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 488FBr5jy2z9sPJ for ; Fri, 31 Jan 2020 22:20:36 +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=XSOTuE+q9+tAlWVpX+HMGWGVI45TR/tF0aVObKLLPbdBzvrHJx2Rl 2n6+XqswjVBG5AnszrQqckKJBVh2xEnpiFZOoR7HaeiBxideAI6wW1aw4F4YGigl TbJJPdUK2WlVOrKIL8EB81v/x87j9MZy2aZHA9wVfucphlL/7HvsYg= 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=h5IwUZLv0GapHeHipq9Cdffe7nU=; b=yxyb7uTJ+9QNPhRDuwGw 4qG+8Y9kvJl1Q9tpRHl/+G932QDqFl+Bnee+WaB9MkmR9qoqJ3579udbE4QHniM4 2YI9ARKQDxEhQVJdBm1JGdvdvKWR4mPq6em29GMmajv6iu0gYoTtkzUDID97waty 7J3lMGyTflGnLTwWksiejLA= Received: (qmail 120287 invoked by alias); 31 Jan 2020 11:20:29 -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 120279 invoked by uid 89); 31 Jan 2020 11:20:28 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-18.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: esa1.mentor.iphmx.com Received: from esa1.mentor.iphmx.com (HELO esa1.mentor.iphmx.com) (68.232.129.153) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 31 Jan 2020 11:20:27 +0000 IronPort-SDR: 6zcKhYWm5bnOQ8EcxvqFI1La88Poa3MygjNnWii7j8lECxSg3uOo94O2d86uWZUFOsbUU8kx/d 8WjKUTLLIAM4aQ2pF/lIpzz1A+MGcq9diukN8Ha8R/YEtLHazGbOHXvKh+wOIWnwItgN530ETB oVgXfNh07p2bzLWOJuh00L653lz8+ZiOPQCqCE2x38ZozTnTACQW1aW9IWi4vZup5BcOfKzKd4 TiFzG25/x0gUfEanwnARVgAO5nagwvRFhMcm6hmJZC1M4DPt4Cut5YAV+MbL7yUoBfy/chRrMS wAo= Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 31 Jan 2020 03:20:25 -0800 IronPort-SDR: cp9BPRZPuKTyeYrz9j1MDMC1XrjwxpVB0n+cRrSFty82ndhIuRE1wvHK751arughNc+G8P3Ab4 dnPB6bBf5bwA== From: Andrew Stubbs Subject: [committed, amdgcn] Zero-initialise masked load destinations To: "gcc-patches@gcc.gnu.org" Message-ID: <3a6e27ba-aad7-8725-a036-6a61ff42fee3@codesourcery.com> Date: Fri, 31 Jan 2020 11:20:14 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 This is one of those things I don't know why we didn't notice sooner. The patch ensures that unused lanes in masked vector loads are zero-initialized, as per the internals manual. This fixes an execution failure in testcase gfortran.dg/assumed_rank_1.f90. When investigating the bug I got confused about the meaning of the "gather_exec" define_expand, which doesn't quite fit the pattern of the other "_exec" instructions. It's only used in one place so I've inlined it to avoid future confusion. It also reduces the likelihood of accidentally bypassing the zero-initialization in future. I also needed a convenient way to create 0.0 vector constants without uglifying the machine description code, so extending gcn_vec_constant seemed like a useful place to do it. Andrew Zero-initialise masked load destinations Fixes an execution failure in testcase gfortran.dg/assumed_rank_1.f90. 2020-01-30 Andrew Stubbs gcc/ * config/gcn/gcn-valu.md (gather_exec): Move contents ... (mask_gather_load): ... here, and zero-initialize the destination. (maskloaddi): Zero-initialize the destination. * config/gcn/gcn.c: diff --git a/gcc/config/gcn/gcn-valu.md b/gcc/config/gcn/gcn-valu.md index 331c768cb88..4aad835b2ef 100644 --- a/gcc/config/gcn/gcn-valu.md +++ b/gcc/config/gcn/gcn-valu.md @@ -701,34 +701,6 @@ DONE; }) -(define_expand "gather_exec" - [(match_operand:VEC_ALLREG_MODE 0 "register_operand") - (match_operand:DI 1 "register_operand") - (match_operand:V64SI 2 "register_operand") - (match_operand 3 "immediate_operand") - (match_operand:SI 4 "gcn_alu_operand") - (match_operand:DI 5 "gcn_exec_reg_operand")] - "" - { - rtx undefmode = gcn_gen_undef (mode); - - rtx addr = gcn_expand_scaled_offsets (DEFAULT_ADDR_SPACE, operands[1], - operands[2], operands[4], - INTVAL (operands[3]), operands[5]); - - if (GET_MODE (addr) == V64DImode) - emit_insn (gen_gather_insn_1offset_exec (operands[0], addr, - const0_rtx, const0_rtx, - const0_rtx, undefmode, - operands[5])); - else - emit_insn (gen_gather_insn_2offsets_exec (operands[0], operands[1], - addr, const0_rtx, - const0_rtx, const0_rtx, - undefmode, operands[5])); - DONE; - }) - ; Allow any address expression (define_expand "gather_expr" [(set (match_operand:VEC_ALLREG_MODE 0 "register_operand") @@ -2801,9 +2773,12 @@ (mode, exec, operands[1], gen_rtx_SCRATCH (V64DImode)); rtx as = gen_rtx_CONST_INT (VOIDmode, MEM_ADDR_SPACE (operands[1])); rtx v = gen_rtx_CONST_INT (VOIDmode, MEM_VOLATILE_P (operands[1])); - rtx undef = gcn_gen_undef (mode); - emit_insn (gen_gather_expr_exec (operands[0], addr, as, v, undef, - exec)); + + /* Masked lanes are required to hold zero. */ + emit_move_insn (operands[0], gcn_vec_constant (mode, 0)); + + emit_insn (gen_gather_expr_exec (operands[0], addr, as, v, + operands[0], exec)); DONE; }) @@ -2843,8 +2818,23 @@ operands[2] = tmp; } - emit_insn (gen_gather_exec (operands[0], operands[1], operands[2], - operands[3], operands[4], exec)); + rtx addr = gcn_expand_scaled_offsets (DEFAULT_ADDR_SPACE, operands[1], + operands[2], operands[4], + INTVAL (operands[3]), exec); + + /* Masked lanes are required to hold zero. */ + emit_move_insn (operands[0], gcn_vec_constant (mode, 0)); + + if (GET_MODE (addr) == V64DImode) + emit_insn (gen_gather_insn_1offset_exec (operands[0], addr, + const0_rtx, const0_rtx, + const0_rtx, operands[0], + exec)); + else + emit_insn (gen_gather_insn_2offsets_exec (operands[0], operands[1], + addr, const0_rtx, + const0_rtx, const0_rtx, + operands[0], exec)); DONE; }) diff --git a/gcc/config/gcn/gcn.c b/gcc/config/gcn/gcn.c index a39e9f3fbd6..16c3aa2567e 100644 --- a/gcc/config/gcn/gcn.c +++ b/gcc/config/gcn/gcn.c @@ -992,9 +992,19 @@ gcn_vec_constant (machine_mode mode, int a) return CONST2_RTX (mode);*/ int units = GET_MODE_NUNITS (mode); - rtx tem = gen_int_mode (a, GET_MODE_INNER (mode)); - rtvec v = rtvec_alloc (units); + machine_mode innermode = GET_MODE_INNER (mode); + + rtx tem; + if (FLOAT_MODE_P (innermode)) + { + REAL_VALUE_TYPE rv; + real_from_integer (&rv, NULL, a, SIGNED); + tem = const_double_from_real_value (rv, innermode); + } + else + tem = gen_int_mode (a, innermode); + rtvec v = rtvec_alloc (units); for (int i = 0; i < units; ++i) RTVEC_ELT (v, i) = tem;