From patchwork Fri Feb 26 15:58:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Jambor X-Patchwork-Id: 589158 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 E46C01402D6 for ; Sat, 27 Feb 2016 02:58:56 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=gMYCTiNV; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=XlrgQMdF46qt+cCRzuYrjCjxql4ebrB6xB/VMwpZcBzeyWgI3G+/v l2BJeW39e+ib5XKdYaBmTgFppRRov2yJyQ0kODEZ2+oZtQS+Y1lLdbp+F+mJwXhq WNsxodcZnti1/8N0cNgYtE4Y+7tnSji9Xdy7EjqYZzp3dN76GnphVE= 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:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=f3NadJ21KbQCXwLjBfYV1FKX8rw=; b=gMYCTiNVWiXw4+krJcsV Sboi0ETxDYBeu1qI/DeNdM+ljeCe+PNBzkVSbko1ZTWrX31TYk2viS/+9Ag77fnr aU5KOubIdZ4pdjJH8/RCVGWKn3Xqfw6c1+8yW5SNJr3/3k46hOb/jT2XPrOUaz0q 6AlHQuS4j887XKYkAbrr4X4= Received: (qmail 121987 invoked by alias); 26 Feb 2016 15:58:50 -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 121970 invoked by uid 89); 26 Feb 2016 15:58:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=*src, UD:operands X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Fri, 26 Feb 2016 15:58:48 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id EE679ACDF for ; Fri, 26 Feb 2016 15:58:44 +0000 (UTC) Date: Fri, 26 Feb 2016 16:58:45 +0100 From: Martin Jambor To: GCC Patches Subject: [hsa/69568] Fix ld instruction type for packed data Message-ID: <20160226155844.GF3094@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-IsSubscribed: yes Hi, this is a fix for another type of HSA immediate operands that we got wrong. Apparently, the immediate value that is to be used in an operation on packed type must be unsigned (unless it is 128bit, then it has to be bit-typed, which is however something we are handling correctly even now). The patch below fulfills that requirement. I have bootstrapped and tested it and will commit it shortly. Thanks, Martin 2016-02-18 Martin Jambor PR hsa/69568 * hsa.h (hsa_type_packed_p): Declare. * hsa.c (hsa_type_packed_p): New function. * hsa-gen.c (mem_type_for_type): Use unsigned type for packed loads. (gen_hsa_insns_for_store): Use hsa_type_packed_p. * hsa-brig.c (emit_basic_insn): Likewise. --- gcc/hsa-brig.c | 2 +- gcc/hsa-gen.c | 6 ++++-- gcc/hsa.c | 8 ++++++++ gcc/hsa.h | 1 + 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c index cfbac58..61cfd8b 100644 --- a/gcc/hsa-brig.c +++ b/gcc/hsa-brig.c @@ -1803,7 +1803,7 @@ emit_basic_insn (hsa_insn_basic *insn) repr.base.type = lendian16 (type); repr.base.operands = lendian32 (emit_insn_operands (insn)); - if ((type & BRIG_TYPE_PACK_MASK) != BRIG_TYPE_PACK_NONE) + if (hsa_type_packed_p (type)) { if (hsa_type_float_p (type) && !hsa_opcode_floating_bit_insn_p (insn->m_opcode)) diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index a295fda..3b915cc 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -754,11 +754,13 @@ mem_type_for_type (BrigType16_t type) unsigned type?). */ if ((type & BRIG_TYPE_PACK_MASK) == BRIG_TYPE_PACK_128) return BRIG_TYPE_B128; - else if (hsa_btype_p (type)) + else if (hsa_btype_p (type) || hsa_type_packed_p (type)) { unsigned bitsize = hsa_type_bit_size (type); if (bitsize < 128) return hsa_uint_for_bitsize (bitsize); + else + return hsa_bittype_for_bitsize (bitsize); } return type; } @@ -2648,7 +2650,7 @@ gen_hsa_insns_for_store (tree lhs, hsa_op_base *src, hsa_bb *hbb) we can modify the above in place. */ if (hsa_op_immed *imm = dyn_cast (src)) { - if ((imm->m_type & BRIG_TYPE_PACK_MASK) == BRIG_TYPE_PACK_NONE) + if (!hsa_type_packed_p (imm->m_type)) imm->m_type = mem->m_type; else { diff --git a/gcc/hsa.c b/gcc/hsa.c index 9537e29..09bfd28 100644 --- a/gcc/hsa.c +++ b/gcc/hsa.c @@ -480,6 +480,14 @@ hsa_unsigned_type_for_type (BrigType16_t t) return hsa_uint_for_bitsize (hsa_type_bit_size (t)); } +/* Return true if TYPE is a packed HSA type. */ + +bool +hsa_type_packed_p (BrigType16_t type) +{ + return (type & BRIG_TYPE_PACK_MASK) != BRIG_TYPE_PACK_NONE; +} + /* Return true if and only if TYPE is a floating point number type. */ bool diff --git a/gcc/hsa.h b/gcc/hsa.h index 275a954..3a13fbd 100644 --- a/gcc/hsa.h +++ b/gcc/hsa.h @@ -1338,6 +1338,7 @@ BrigType16_t hsa_uint_for_bitsize (unsigned bitsize); BrigType16_t hsa_float_for_bitsize (unsigned bitsize); BrigType16_t hsa_bittype_for_type (BrigType16_t t); BrigType16_t hsa_unsigned_type_for_type (BrigType16_t t); +bool hsa_type_packed_p (BrigType16_t type); bool hsa_type_float_p (BrigType16_t type); bool hsa_type_integer_p (BrigType16_t type); bool hsa_btype_p (BrigType16_t type);