From patchwork Wed Nov 2 17:40:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Greenhalgh X-Patchwork-Id: 80522 Delivered-To: patch@linaro.org Received: by 10.80.170.210 with SMTP id r18csp230422edc; Wed, 2 Nov 2016 10:41:30 -0700 (PDT) X-Received: by 10.99.112.65 with SMTP id a1mr7393827pgn.31.1478108489991; Wed, 02 Nov 2016 10:41:29 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id m19si3494846pag.320.2016.11.02.10.41.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Nov 2016 10:41:29 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-440247-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-440247-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-440247-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:from :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; q=dns; s=default; b=mRExDSTIoGP4F8lP jCpAuB9jhrrL6Lk0NN+wzpSEMsrfab3Tp9+lIk+i69KKRlX/h9ic0seIiVBoTEah ujZYaHrbUyxPaJoogaodX81bohn7v+YdrPV5JrhJ5wgdPLw8XFnNriUk4/a64nxI XJHxgszYl/KSs/gVsZRXMp0IAh8= 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 :to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type; s=default; bh=JOVLbLROMN5Uduy0Y5zW3y tP7sA=; b=EeAtm6dHe3idLDZkp60aDB9GFyRfx2/tVdSN4jhISAYomABx3ZaiV4 jFkn4gzipmWKFkknuRDM4RBnJqgZtaO9NS6heIm5yZi+vaI9M/N9gqbXO2atieQ0 FNNpBZpptA3h3ALs+VcKX9jlKNe7naqp8bhZzgCVGDYUNhKfgjiKo= Received: (qmail 5919 invoked by alias); 2 Nov 2016 17:41:10 -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 5905 invoked by uid 89); 2 Nov 2016 17:41:09 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy=rounded, float_type_node, rounding, sk:flag_un X-HELO: EUR03-DB5-obe.outbound.protection.outlook.com Received: from mail-eopbgr40049.outbound.protection.outlook.com (HELO EUR03-DB5-obe.outbound.protection.outlook.com) (40.107.4.49) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 02 Nov 2016 17:40:59 +0000 Received: from DB5PR08CA0057.eurprd08.prod.outlook.com (10.166.166.153) by AM4PR08MB0851.eurprd08.prod.outlook.com (10.164.83.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12; Wed, 2 Nov 2016 17:40:55 +0000 Received: from DB3FFO11FD008.protection.gbl (2a01:111:f400:7e04::127) by DB5PR08CA0057.outlook.office365.com (2a01:111:e400:c576::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.693.12 via Frontend Transport; Wed, 2 Nov 2016 17:40:55 +0000 Authentication-Results: spf=pass (sender IP is 217.140.96.140) smtp.mailfrom=arm.com; codesourcery.com; dkim=none (message not signed) header.d=none; codesourcery.com; dmarc=bestguesspass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 217.140.96.140 as permitted sender) receiver=protection.outlook.com; client-ip=217.140.96.140; helo=nebula.arm.com; Received: from nebula.arm.com (217.140.96.140) by DB3FFO11FD008.mail.protection.outlook.com (10.47.216.97) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.693.6 via Frontend Transport; Wed, 2 Nov 2016 17:40:55 +0000 Received: from e107456-lin.cambridge.arm.com (10.1.2.79) by mail.arm.com (10.1.106.66) with Microsoft SMTP Server id 14.3.294.0; Wed, 2 Nov 2016 17:40:39 +0000 From: James Greenhalgh To: CC: , , , , Subject: Re: [Patch 3/4] Half to double precision conversions Date: Wed, 2 Nov 2016 17:40:37 +0000 Message-ID: <1478108437-32222-1-git-send-email-james.greenhalgh@arm.com> In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:217.140.96.140; IPV:CAL; SCL:-1; CTRY:GB; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(189002)(24454002)(199003)(377424004)(5890100001)(50226002)(568964002)(106466001)(4610100001)(586003)(189998001)(84326002)(2476003)(36756003)(33646002)(19580395003)(356003)(19580405001)(305945005)(7846002)(26826002)(246002)(5660300001)(87936001)(110136003)(626004)(92566002)(77096005)(2950100002)(76176999)(50986999)(104016004)(4326007)(2906002)(11100500001)(2351001)(8936002)(86362001)(6916009)(512874002)(8676002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR08MB0851; H:nebula.arm.com; FPR:; SPF:Pass; PTR:fw-tnat.cambridge.arm.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1;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WH9kkV+m33LEwTaEBqLoctGspXl/Na6pHwbZSlKXLzJyMo73XmKWEyo8EilsRmbin4lqV/iqfifIceNmcKOz9A731VbRIx1eEPs742vvGIVEnv8mdbXGtPkhzaleDfJPVS1n8eSKy5qNXxIMMcpIS1/j2OhlwSomamEMjk= X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(8251501002); SRVR:AM4PR08MB0851; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0851; 25:gH4A2PutntPkGDDU1WoY/YfF4ceI0fEsiO/zI6dZnTVSfjYCDBrv4zU4hokcDURpf7Qf+aH0UqJIkYsG63THjVf5SGT+2B44u4v/8QxDU6zNm4CoagW5P1aTuZvRTmeRiOzQgpYEVkIiiBekYn2s5UK4xuO6juzckEcYjzQej3PCj3MnMWQ4lvivlgAtfDjSqj1hcx57bEMMwhdtnpzzNY8nzIIcQCvbr2APFfUKBZpcc5IP5twgKAi/w4QJVOVzm8BIDlQGl42KBh3CJcgBktB1ENKZDr7KTHXha/pRva6zWBHQqrbGc0KYXl0qw5AQ/oGrc+8Gq9Kd5eyHhRl3+AKW79TiU4YRVoUjBKBzsykokxlAxkTbd/qMOyX/kerwJJkexRiV5uHfmt7F/IXF6QCqf06m9Ma67r59bkLVoCBRfbTT+G94GdBnDrZ0LGftHpnyZyZvXfcaCI5LNBY6MYS/DhLRh165cApPIJZ9QKpqrhAGNS+/2+Rd3RXbAyF2P0cpkRm/6QnL9IlSgQ6CmpADX3sVQbCC8Au+uA+hdo1eSslvQS7P8SY8xSQWYuFw819gzkZlZcYEWlIORKf+L0jcO55Ucd7X2rDcXzVB81qyskmWqt8yf9fDpVzSl3OKKiI3Vq0EL+26RUTaWpC9cSueD9KH057Vf0eHrsPjR5+sLNwZ6CCXCENrXMsHO1bXCf6YBKOcGV8lroEex1+X60O73NueGAk0kNsVBxn6ExuWaNIMgvZonk6i9n5YHrV4Y2oMQpNIU8gziBfSVS3gQZcqxExNeWcGR2Tb2ApMbviyshBlvQ0m4Ibt/omPXCuica0H4DpiCu38aSf1WpHvN2+Si/NLy/269s4MpkjKedHixRWCW8uZgNgdqE7XmWwCGf4Hy+78FesuYxo+/9FVEwxw9AH/3KG5XofKUTzhxUQ= X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0851; 31:g4q70sTOcpw1m+yCcWCVKl2rjUC5qLN9NdK8gk61MnpNJ96PSum00N4GDiN/canQb8qc7IosgsBamavbMaOUzg9cPEx+49LiUGENxkkAdS8yk24FtSHZvk8tWq25Djn6NLqT/M3G9/KE9CIIdrOW3ysW9yrgeBdmQJI0i59qyjsRWHXRcdlNVKIUNOBItq9O/2+YyVrDk073+EKaqN0uWReYHg0Cl47/i8M2ipRpjAcTe0i12d9cK1PKt5/hOUBv1OeVY/DmVIqCLpq/MEvvmWoAU1ZD1FkHzKBMnN3taweBlh6RLv37tGIEwDte5I64; 20:un9iatWA0lsoSWcJOA2Ilb6DLg8/5X8HFheZR1oKY8C3C0E5lwTi0WQ5dyqLzEE0RvYOTzg7NYgZymCGa1LFioI/zAu97K4dD4R/KZAJdCNo5FNSvwcfy6F411SVni52RVobgj4dB3Oxw70WJdnLyErG4/rJLCei915H2l8JdzrIKaxLBAEsCtqri+cHslyYzFbmfKNYVBeMear3dj3bOUHu4MQhw+jjnADfgVVzX64OVsLlxLT7tO/uiYanw0pd NoDisclaimer: True X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(102415321)(6040176)(601004)(2401047)(13024025)(5005006)(13013025)(13020025)(8121501046)(13023025)(3002001)(10201501046)(6055026); SRVR:AM4PR08MB0851; BCL:0; PCL:0; RULEID:; SRVR:AM4PR08MB0851; X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0851; 4:IH0RIZF1BIVnWstjOL153MIdvDsBTNNOxxWMotdc22ffQgezI+hSq0M7jen4i8JEeO2nn2Caadrr1XnBksv/1Zvqu+Iyt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RZ53uNQ/jkwMMYu47+r4QAOQDCNvDpcStp30eiEvVA9hqulkDvVjIJugLZje8Sgnlm26bG/jXgoBiQcde/DvThipHSQrSobwd7C1KFhSFp7dJ1slr0mTDakYP9ekfCdNxoicsaGaC5geoh3pGq+8mUcmfpjxqa6nPOho7ESLpfivgNQIJQszSc3s0dfSlhv1oJJTGjGMWDYn9TdUbqXmuQrodPbQ=; 5:BqOq6JWdXlD110fDnodHtytBn+39ZLGm4cR+2UOY3MUBHMGNoXySu0kp/pNBQQyuwzZcbsJp0eFvZIEzVW3b1CxjkexRDRcXXd+wqTVD3dMVGV0K8+9PsXbjJNmrUV3W4ZjeEXstkACP0JAUkiAZTg==; 24:Ppn/2HfJ20VRI5PbTlbAakUJg7JqJ4W30+yqmt++4zMMts6m2iIKHnnLQicuVCOlYcK6HOmUimbF7uaxBl2tyRrlV2dl4eyg1t40dXuizqk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; AM4PR08MB0851; 7:dkRcwx4VpIgUo9pli670+QHP0AEMvfTQ6K+ERmD0qa9FfSVFu5Oy/of/kbw+o+zFLr56BYLX/5k0RbNucxBxIuIm3ViAZqvqQfE0FmqIj1BCv9S0Fff2UmS6PZ1PASvew/UsXw1RQYTEhHQZaxSwOdKaW1kNW8q2jbvTWicaI8CAZBVcIzX4DmDTY+G9ChEYEMyoCC9TJDHdq/3fk2AsShHcAb8or63m7quQB3Z40JjQPb4DaXOPsDhJaFiq/0Bau7Le8OUogVna9hBBEVzEWUmKMp7q9CHWI2fqo5vN7Mivc6lYfnqC7V4uW7CfQFf9jGn71jLPlHjSiFTMFhioU/+DeH23fbFB1nn69lBm9mw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2016 17:40:55.3239 (UTC) X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[217.140.96.140]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB0851 X-IsSubscribed: yes On Mon, Oct 24, 2016 at 10:24:27PM +0000, Joseph Myers wrote: > On Mon, 24 Oct 2016, James Greenhalgh wrote: > > > Conversions from double precision floats to the ARM __fp16 are required > > to round only once. > > I'd expect that when fixing this you need to update > gcc.target/arm/fp16-rounding-ieee-1.c (and fp16-rounding-alt-1.c, I > suppose) to expect rounding once. But I don't see such a testsuite change > anywhere in this patch series. Right, I went back and checked my ARM test environment. Sure enough it was producing nonsense results. I've fixed my build system issue, which causes these tests to start failing as you predicted. I've now fixed them in this patch revision to use the value they would return if rounding happened directly rather than first through SFmode. Thanks, James --- gcc/ 2016-11-02 James Greenhalgh * config/arm/arm.c (arm_convert_to_type): Delete. (TARGET_CONVERT_TO_TYPE): Delete. (arm_init_libfuncs): Enable trunc_optab from DFmode to HFmode. (arm_libcall_uses_aapcs_base): Add trunc_optab from DF- to HFmode. * config/arm/arm.h (TARGET_FP16_TO_DOUBLE): New. * config/arm/arm.md (truncdfhf2): Only convert through SFmode if we are in fast math mode, and have no single step hardware instruction. (extendhfdf2): Only expand through SFmode if we don't have a single-step hardware instruction. * config/arm/vfp.md (*truncdfhf2): New. (extendhfdf2): Likewise. gcc/testsuite/ 2016-11-02 James Greenhalgh * gcc.target/arm/fp16-rounding-alt-1.c (ROUNDED): Change expected result. * gcc.target/arm/fp16-rounding-ieee-1.c (ROUNDED): Change expected result. diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 8ce4e4e..524c474 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -251,7 +251,6 @@ static bool arm_output_addr_const_extra (FILE *, rtx); static bool arm_allocate_stack_slots_for_args (void); static bool arm_warn_func_return (tree); static tree arm_promoted_type (const_tree t); -static tree arm_convert_to_type (tree type, tree expr); static bool arm_scalar_mode_supported_p (machine_mode); static bool arm_frame_pointer_required (void); static bool arm_can_eliminate (const int, const int); @@ -660,9 +659,6 @@ static const struct attribute_spec arm_attribute_table[] = #undef TARGET_PROMOTED_TYPE #define TARGET_PROMOTED_TYPE arm_promoted_type -#undef TARGET_CONVERT_TO_TYPE -#define TARGET_CONVERT_TO_TYPE arm_convert_to_type - #undef TARGET_SCALAR_MODE_SUPPORTED_P #define TARGET_SCALAR_MODE_SUPPORTED_P arm_scalar_mode_supported_p @@ -2565,6 +2561,11 @@ arm_init_libfuncs (void) ? "__gnu_h2f_ieee" : "__gnu_h2f_alternative")); + set_conv_libfunc (trunc_optab, HFmode, DFmode, + (arm_fp16_format == ARM_FP16_FORMAT_IEEE + ? "__gnu_d2h_ieee" + : "__gnu_d2h_alternative")); + /* Arithmetic. */ set_optab_libfunc (add_optab, HFmode, NULL); set_optab_libfunc (sdiv_optab, HFmode, NULL); @@ -5314,6 +5315,8 @@ arm_libcall_uses_aapcs_base (const_rtx libcall) SFmode)); add_libcall (libcall_htab, convert_optab_libfunc (trunc_optab, SFmode, DFmode)); + add_libcall (libcall_htab, + convert_optab_libfunc (trunc_optab, HFmode, DFmode)); } return libcall && libcall_htab->find (libcall) != NULL; @@ -23742,23 +23745,6 @@ arm_promoted_type (const_tree t) return NULL_TREE; } -/* Implement TARGET_CONVERT_TO_TYPE. - Specifically, this hook implements the peculiarity of the ARM - half-precision floating-point C semantics that requires conversions between - __fp16 to or from double to do an intermediate conversion to float. */ - -static tree -arm_convert_to_type (tree type, tree expr) -{ - tree fromtype = TREE_TYPE (expr); - if (!SCALAR_FLOAT_TYPE_P (fromtype) || !SCALAR_FLOAT_TYPE_P (type)) - return NULL_TREE; - if ((TYPE_PRECISION (fromtype) == 16 && TYPE_PRECISION (type) > 32) - || (TYPE_PRECISION (type) == 16 && TYPE_PRECISION (fromtype) > 32)) - return convert (type, convert (float_type_node, expr)); - return NULL_TREE; -} - /* Implement TARGET_SCALAR_MODE_SUPPORTED_P. This simply adds HFmode as a supported mode; even though we don't implement arithmetic on this type directly, it's supported by diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index fa8e84c..0f9a679 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -194,6 +194,11 @@ extern void (*arm_lang_output_object_attributes_hook)(void); #define TARGET_FP16 \ (ARM_FPU_FSET_HAS (TARGET_FPU_FEATURES, FPU_FL_FP16)) +/* FPU supports converting between HFmode and DFmode in a single hardware + step. */ +#define TARGET_FP16_TO_DOUBLE \ + (TARGET_HARD_FLOAT && (TARGET_FP16 && TARGET_VFP5)) + /* FPU supports fused-multiply-add operations. */ #define TARGET_FMA (TARGET_FPU_REV >= 4) diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 8393f65..4074773 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -5177,20 +5177,35 @@ "" ) -;; DFmode to HFmode conversions have to go through SFmode. +;; DFmode to HFmode conversions on targets without a single-step hardware +;; instruction for it would have to go through SFmode. This is dangerous +;; as it introduces double rounding. +;; +;; Disable this pattern unless we are in an unsafe math mode, or we have +;; a single-step instruction. + (define_expand "truncdfhf2" - [(set (match_operand:HF 0 "general_operand" "") + [(set (match_operand:HF 0 "s_register_operand" "") (float_truncate:HF - (match_operand:DF 1 "general_operand" "")))] - "TARGET_EITHER" - " - { - rtx op1; - op1 = convert_to_mode (SFmode, operands[1], 0); - op1 = convert_to_mode (HFmode, op1, 0); - emit_move_insn (operands[0], op1); - DONE; - }" + (match_operand:DF 1 "s_register_operand" "")))] + "(TARGET_EITHER && flag_unsafe_math_optimizations) + || (TARGET_32BIT && TARGET_FP16_TO_DOUBLE)" +{ + /* We don't have a direct instruction for this, so we must be in + an unsafe math mode, and going via SFmode. */ + + if (!(TARGET_32BIT && TARGET_FP16_TO_DOUBLE)) + { + rtx op1; + gcc_assert (flag_unsafe_math_optimizations); + op1 = convert_to_mode (SFmode, operands[1], 0); + op1 = convert_to_mode (HFmode, op1, 0); + emit_move_insn (operands[0], op1); + DONE; + } + /* Otherwise, we will pick this up as a single instruction with + no intermediary rounding. */ +} ) ;; Zero and sign extension instructions. @@ -5684,19 +5699,28 @@ "" ) -;; HFmode -> DFmode conversions have to go through SFmode. +;; HFmode -> DFmode conversions where we don't have an instruction for it +;; must go through SFmode. +;; +;; This is always safe for an extend. + (define_expand "extendhfdf2" - [(set (match_operand:DF 0 "general_operand" "") - (float_extend:DF (match_operand:HF 1 "general_operand" "")))] + [(set (match_operand:DF 0 "s_register_operand" "") + (float_extend:DF (match_operand:HF 1 "s_register_operand" "")))] "TARGET_EITHER" - " - { - rtx op1; - op1 = convert_to_mode (SFmode, operands[1], 0); - op1 = convert_to_mode (DFmode, op1, 0); - emit_insn (gen_movdf (operands[0], op1)); - DONE; - }" +{ + /* We don't have a direct instruction for this, so go via SFmode. */ + if (!(TARGET_32BIT && TARGET_FP16_TO_DOUBLE)) + { + rtx op1; + op1 = convert_to_mode (SFmode, operands[1], 0); + op1 = convert_to_mode (DFmode, op1, 0); + emit_insn (gen_movdf (operands[0], op1)); + DONE; + } + /* Otherwise, we're done producing RTL and will pick up the correct + pattern to do this with one rounding-step in a single instruction. */ +} ) ;; Move insns (including loads and stores) diff --git a/gcc/config/arm/vfp.md b/gcc/config/arm/vfp.md index 45ce5c9..cb23c7f 100644 --- a/gcc/config/arm/vfp.md +++ b/gcc/config/arm/vfp.md @@ -1507,6 +1507,26 @@ (set_attr "type" "f_cvt")] ) +(define_insn "*truncdfhf2" + [(set (match_operand:HF 0 "s_register_operand" "=t") + (float_truncate:HF (match_operand:DF 1 "s_register_operand" "w")))] + "TARGET_32BIT && TARGET_FP16_TO_DOUBLE" + "vcvtb%?.f16.f64\\t%0, %P1" + [(set_attr "predicable" "yes") + (set_attr "predicable_short_it" "no") + (set_attr "type" "f_cvt")] +) + +(define_insn "*extendhfdf2" + [(set (match_operand:DF 0 "s_register_operand" "=w") + (float_extend:DF (match_operand:HF 1 "s_register_operand" "t")))] + "TARGET_32BIT && TARGET_FP16_TO_DOUBLE" + "vcvtb%?.f64.f16\\t%P0, %1" + [(set_attr "predicable" "yes") + (set_attr "predicable_short_it" "no") + (set_attr "type" "f_cvt")] +) + (define_insn "truncsfhf2" [(set (match_operand:HF 0 "s_register_operand" "=t") (float_truncate:HF (match_operand:SF 1 "s_register_operand" "t")))] diff --git a/gcc/testsuite/gcc.target/arm/fp16-rounding-alt-1.c b/gcc/testsuite/gcc.target/arm/fp16-rounding-alt-1.c index 1c15b61..27bb40d 100644 --- a/gcc/testsuite/gcc.target/arm/fp16-rounding-alt-1.c +++ b/gcc/testsuite/gcc.target/arm/fp16-rounding-alt-1.c @@ -1,6 +1,6 @@ -/* Test intermediate rounding of double to float and then to __fp16, using - an example of a number that would round differently if it went directly - from double to __fp16. */ +/* Test that rounding double to __fp16 happens directly, using an example + of a number that would round differently if it went from double to + __fp16 via float. */ /* { dg-do run } */ /* { dg-require-effective-target arm_fp16_alternative_ok } */ @@ -11,8 +11,8 @@ /* The original double value. */ #define ORIG 0x1.0020008p0 -/* The expected (double)((__fp16)((float)ORIG)) value. */ -#define ROUNDED 0x1.0000000p0 +/* The expected (double)((__fp16)ORIG) value. */ +#define ROUNDED 0x1.0040000p0 typedef union u { __fp16 f; diff --git a/gcc/testsuite/gcc.target/arm/fp16-rounding-ieee-1.c b/gcc/testsuite/gcc.target/arm/fp16-rounding-ieee-1.c index 866d4d8..194dc9d 100644 --- a/gcc/testsuite/gcc.target/arm/fp16-rounding-ieee-1.c +++ b/gcc/testsuite/gcc.target/arm/fp16-rounding-ieee-1.c @@ -1,6 +1,6 @@ -/* Test intermediate rounding of double to float and then to __fp16, using - an example of a number that would round differently if it went directly - from double to __fp16. */ +/* Test that rounding double to __fp16 happens directly, using an example + of a number that would round differently if it went from double to + __fp16 via float. */ /* { dg-do run } */ /* { dg-options "-mfp16-format=ieee" } */ @@ -10,8 +10,8 @@ /* The original double value. */ #define ORIG 0x1.0020008p0 -/* The expected (double)((__fp16)((float)ORIG)) value. */ -#define ROUNDED 0x1.0000000p0 +/* The expected (double)((__fp16)ORIG) value. */ +#define ROUNDED 0x1.0040000p0 typedef union u { __fp16 f;