From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by sourceware.org (Postfix) with ESMTPS id D847F3857C48 for ; Wed, 23 Nov 2022 12:59:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D847F3857C48 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yb1-xb36.google.com with SMTP id d128so2276715ybf.10 for ; Wed, 23 Nov 2022 04:59:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=FgR7qPeG2OUJOlD5ZeQ2/FJ0F4uJCBVIGzGyICh8n8w=; b=HaVHk/3i34NZO1eu1bKS0aAyCUhp1djcVZU4BLkzF2V6AjPPAuZOMgQJWJILMihTSn 9+8Hu4ijll8OgMm1beQkz0H4ywGIaQdAOlkNt8a8xI2sTRR9yF2sQ8UfutuVfhntvqF5 jmulHzEgsY3lBH0024HEQeHDOUwJCdfcIdfcoVy70Dxc8PrLTIZro3XBbYZxnKqHaULv NB+IjLJUMlQ43/2ustMFLtT5zLRkU5fPFs7Aei2gPyrnv0Is7BLANEcQiNb9aH4U3qi1 qjd+xSIlSRhLhC4uXWNUgiPviPhLld3sLHb4E25bn67pnHo5AYXtUjcFOPWI4GykkiNh a3cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=FgR7qPeG2OUJOlD5ZeQ2/FJ0F4uJCBVIGzGyICh8n8w=; b=zEtcnojoMGH4L7EMFc8O4RcXQUXNbDZG7VsSBRv0MSWYqDVXnIRBFQW3XBZ1+hk70D tQIdxPpZ/Bl1CQ19JIqIU9YVCxLqnwODRPPWd8Pk6WxgyEb/Qchq0REgvM0hUMRwkLnd fUJYJEr+4XM2vtlC6vT9HPp3eO9/92YcdWU+Oh0lS+KR14XAzUp8v9Yd47SFEjXPIIwH irGSNrZZvivIeFBrtN5VraODEfdvL/CfdTUHMM/WxW4UZcJORfkGRRciUWLSPbJR4jIo wp3w4tYZTTLDmIK6UvuiQRdiyqtXilm3bkmq0xHQj+kX3aRkup8fXlUHC+R3GnmSml9a o98w== X-Gm-Message-State: ANoB5pmWdElwsbI5V0QcLxq+taMWnt2k2MRS6X6hg2c35ljr2gn4GWKL v98HaAe3iS33X9f50UKKvLniIPAGoc3TJk5/b5s= X-Google-Smtp-Source: AA0mqf6jXzmYM3sjqN6XP1wxwwvLW6gwj9E3awWNY+2sXtj2FgjZroSnaHp4JWsTVit6acYGz/ghN5vX/UO4QcXHwdY= X-Received: by 2002:a25:e80f:0:b0:6df:927f:38c9 with SMTP id k15-20020a25e80f000000b006df927f38c9mr25298900ybd.92.1669208352225; Wed, 23 Nov 2022 04:59:12 -0800 (PST) MIME-Version: 1.0 References: <20221123122820.3150670-1-hongtao.liu@intel.com> In-Reply-To: From: Hongtao Liu Date: Wed, 23 Nov 2022 20:59:00 +0800 Message-ID: Subject: Re: [PATCH] [x86] Fix incorrect implementation for mm_cvtsbh_ss. To: Jakub Jelinek Cc: liuhongt , gcc-patches@gcc.gnu.org, hjl.tools@gmail.com, ubizjak@gmail.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Nov 23, 2022 at 8:40 PM Jakub Jelinek wrote: > > On Wed, Nov 23, 2022 at 08:28:20PM +0800, liuhongt via Gcc-patches wrote: > > After supporting real __bf16 type, implementation of mm_cvtsbh_ss went wrong. > > The patch supports extendbfsf2/truncsfbf2 with pslld/psrld, > > and then refined the intrinsic with implicit conversion. > > This is not correct. > While using such code for _mm_cvtsbh_ss is fine if it is documented not to > raise exceptions and turn a sNaN into a qNaN, it is not fine for HONOR_NANS > (i.e. when -ffast-math is not on), because a __bf16 -> float conversion > on sNaN should raise invalid exception and turn it into a qNaN. > We could have extendbfsf2 expander that would FAIL; if HONOR_NANS and > emit extendbfsf2_1 otherwise. I see, i'll use target specific builtin and generate psrld just for the intrinsic, and drop the expander part. > > And the truncsfbf2 case isn't correct IMHO even for -ffast-math. > float -> __bf16 conversion should be properly rounding depending on the > current rounding mode, while {,v}psrld will always round toward zero. > > Jakub > -- BR, Hongtao