From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id B2EAC3858033 for ; Wed, 23 Nov 2022 12:40:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B2EAC3858033 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669207241; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=e6ybC6HZHeAuOa+AjkDt2nflj+hDvcmZjWhkVnYqsag=; b=LbL/25b5gM4ncjc2uu0Z6mJ/GVr/C/YUzgnm3PD/Po1hzEvALUQbBNvZ4TfxS4Xny1KpVb jDCmK7pXid96CVDpj6OO8xbVREoRe3HLeXpbbU1MtNfhSaDoogKprMT8S+huAyx6OLIu9C WvtLgVsmMfKMAtBoe+Jr4aKwtmncyKQ= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-439-Dm0xHVC4MGupg36Mj1J0-g-1; Wed, 23 Nov 2022 07:40:39 -0500 X-MC-Unique: Dm0xHVC4MGupg36Mj1J0-g-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0219800B23; Wed, 23 Nov 2022 12:40:38 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.194.202]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5D002111E414; Wed, 23 Nov 2022 12:40:38 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2ANCeXa92535543 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 23 Nov 2022 13:40:33 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2ANCeVRO2535542; Wed, 23 Nov 2022 13:40:31 +0100 Date: Wed, 23 Nov 2022 13:40:31 +0100 From: Jakub Jelinek To: liuhongt Cc: gcc-patches@gcc.gnu.org, crazylht@gmail.com, hjl.tools@gmail.com, ubizjak@gmail.com Subject: Re: [PATCH] [x86] Fix incorrect implementation for mm_cvtsbh_ss. Message-ID: Reply-To: Jakub Jelinek References: <20221123122820.3150670-1-hongtao.liu@intel.com> MIME-Version: 1.0 In-Reply-To: <20221123122820.3150670-1-hongtao.liu@intel.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,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 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. 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