From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 6A13C385780A for ; Thu, 1 Jul 2021 21:17:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 6A13C385780A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: IsdnorzgrZaQXQvPlxhb3r+QWBC9NUX37CW9q0X6MvcvqnK0Cfaiu4hqj4BMAyHhOw0IDPieU8 aDsoE0kbNiAcVxGUoYCuvYcTGqTx28+KsZDH8wmdZJvFLte4Tf75MIt32wf/kDXtLBppjRem1m m+/rH7eiPO1WLfAwg+Za0wX66Y9pVZZLSEA9de+eXSc3/HMQk4Sox7GhkcmdMJxFKZwOhlc7XL vegUrsLadDJiAM6Fc5TwEQ5pZmbnzLkZocWILPZSpBtvDV6NlwjGwibPvxFGo6dlvExOsBUske 7Ww= X-IronPort-AV: E=Sophos;i="5.83,315,1616486400"; d="scan'208";a="65499357" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa1.mentor.iphmx.com with ESMTP; 01 Jul 2021 13:17:20 -0800 IronPort-SDR: W0it6Du1hESlLTiUHftNpaBUXL46vKNSGuXOM+B1UCBXNXXjryYmGuREKGig9tSF+ivl/rjfio KPQYmm8eQbmhzeQSRoJEwHVUEqh4LgU370+BWl5BL9SRW0Ye0BI/Bz3JKnPo5R6FPeyLYob0MJ Wf07XTbCIi8NtEaFwe4sCRVczaDNOtN4e06NoaUgmjRv/Ch70UpYtDzFyAPy3aTUASgrpcQgOv rPhRj80SrJTLwjcpXz8znsL9f4UuP44kqj0lAMgLvKLIKD9UM6KM5Y1sM10FeQchKykDOJA0oA Mso= Date: Thu, 1 Jul 2021 21:17:15 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: liuhongt CC: , Subject: Re: [PATCH 56/62] AVX512FP16: Optimize (_Float16) sqrtf ((float) f16) to sqrtf16 (f16). In-Reply-To: <20210701061648.9447-57-hongtao.liu@intel.com> Message-ID: References: <20210701061648.9447-1-hongtao.liu@intel.com> <20210701061648.9447-57-hongtao.liu@intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: SVR-IES-MBX-07.mgc.mentorg.com (139.181.222.7) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3120.2 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jul 2021 21:17:22 -0000 On Thu, 1 Jul 2021, liuhongt via Gcc-patches wrote: > +/* Optimize for code like (_Float16) __builtin_sqrtf ((float) f16) > + since it's not handled in frontend. */ If correct, it *should* be handled in front end (well, middle-end). See what convert.c:convert_to_real_1 does, with a long comment about when it's safe for sqrt (the comment says it's safe when P1 >= P2*2+2, which is true for SFmode and HFmode). The issue (apart from convert_to_real_1 being earlier than this really ought to be done - something based on match.pd would be better - but you can ignore that for now) would be the limitation earlier in that code to the modes of float and double: /* Disable until we figure out how to decide whether the functions are present in runtime. */ /* Convert (float)sqrt((double)x) where x is float into sqrtf(x) */ if (optimize && (TYPE_MODE (type) == TYPE_MODE (double_type_node) || TYPE_MODE (type) == TYPE_MODE (float_type_node))) In this case, you *don't* have the sqrtf16 function in the runtime library (adding _Float16 support to glibc would be good, but runs into various other complications that would need considering, especially questions of how if at all it can be added on an architecture before the minimum GCC version for building glibc for that architecture is recent enough to support _Float16 for that architecture). So effectively what you'd need is some way of saying "__builtin_sqrtf16 is available", where "available" for now means "will be expanded inline", i.e. some combination of !flag_math_errno and instruction set features. That's not really within the scope of what the libc_has_function hook does, but it could maybe be extended to take information about the exact function in question, or another similar hook could be added. -- Joseph S. Myers joseph@codesourcery.com