From patchwork Sun Dec 10 08:55:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Andrew Pinski (QUIC)" X-Patchwork-Id: 176309 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp6425212vqy; Sun, 10 Dec 2023 00:56:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZJ7j4fH3RNDRoCWiDgG0iehfn0wfJqHYBYoG5Km69C2r18hhvgpqYFqT9YuzPycBvicaN X-Received: by 2002:a05:6214:8e3:b0:67a:a721:f33c with SMTP id dr3-20020a05621408e300b0067aa721f33cmr3159410qvb.124.1702198601338; Sun, 10 Dec 2023 00:56:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1702198601; cv=pass; d=google.com; s=arc-20160816; b=z0aOXzHmMPezxu+7LT9lOVWWiqEc8OYRpTTHi444Sa01qJV8IGYprAMHC6C8IwbBFl 53XDypRlapdhKlNmE9hDackr8/25/qNRRSkgJPIZpB0sa00qP0I4wZTInrsrjknJMpKR yEjCbOJBqWZQtwy+h3kJYU4tHuHAafWWNCclQp2H3Z0UGPjjH2vRobs4LlYmh+EWmjxx 8GFIQy6MV7REH+TWn8c3v52rWcH16llJGYFcwvqt9FN2ehi3OwylflG23ts8IVo5ou05 ejuvEQNyLOykc20zqIN2JkOVpH46rMbja59yjM7VJDk+7NeI7ZGJB7MD++XDo/1ZIUXA UnIg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=mzgCVeV8xHeAMMs4Wec6xL3bPT9Am2xumX3cZyeA9LM=; fh=gk9A5O7Gbglvz1MjrRQ4hZ2i3c68kYkpOZJg1emXh+g=; b=H0Fs6l7im5CjjLp1RYqssJ7QiDdB4pWrby7RFc13DzCKeHPRB20+4uD+5gE6bKm+0/ epGH5fijcGSVysq/ExWTKrRl9suHf/5Mjx6IxCH6e0yTBL8dhtyfEYb1SLjpJrjPIUMo PeSlJGRKzjamtQClN8c4EIip41cQc/j/9IT0bohryn4W8RfK/inhU7Mwh7rPGJPSbEE3 rLBPJ31O/Smvauk8+Sk52DWmUyXPEHjSG8GcKWdw4Lxvbw0JYQdsoMxdp+QBQQ4u07tp zNaz5WN5U7+Wg8JdcCy92QjnvAVBHZBrT/i1WpS06cOCt4qONcMJWKSQgeYhkCQlURZG 8oDA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="cCgv/lnv"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s12-20020ad4438c000000b0067a9ea909a4si6003296qvr.14.2023.12.10.00.56.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 00:56:41 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b="cCgv/lnv"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A9763858CD1 for ; Sun, 10 Dec 2023 08:56:41 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id 765553858D1E for ; Sun, 10 Dec 2023 08:55:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 765553858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 765553858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702198561; cv=none; b=gLH/c3KgcYWYl+pWU0pRY5nJtzMpnJfYgWBscQDydSPeFIhpzzSESJhtCHlE9DCEgU+BDVT0PFn68TykwKatwZB35EjHsZ73riU2lWNNgrxjO6wKdd6QnuvUPn7RVu+bkHPB3ZGMPrDkMzBLNAvwR48UCYmzCskFFRJz35Vcs38= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1702198561; c=relaxed/simple; bh=NDikkXKuUQgu3WGcJcQRgaDfJaVc+ueiE+jjnlur0z4=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=VSoRocHyrlQmRjDEkEPWBAi3b1i/vDUwrPQxWmPGlEMfidgys4e8O9GsjjGRKzRmfTpi/l6yVAE3S/FAegsgi7bYzBG6w/5Xk2CW79J/2QqmGSWYfDotWu+7g+0pSVWyb6jyZhJRZ7/UtVG5sJ3HtzuJ/eHAQBoYc8UYhx5q8TY= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BA8sUBm016155 for ; Sun, 10 Dec 2023 08:55:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=qcppdkim1; bh=mzgCVeV 8xHeAMMs4Wec6xL3bPT9Am2xumX3cZyeA9LM=; b=cCgv/lnv2JlOuwpqIrIWbdP eC4/GADleeb0lW2LOc+fA/v8BYiM7Igr/uC+poCUfpXGADrUR84ksbmLuhgMP7yc apyuGWI17/mWGdBHmW2Dsh1e1J5wZBEKh9nCrXUwGVUwxmJsDoEOrQ1CdcpS2bGo qkSJIVGEPLNraPuVWxxcNRQ3VqTD4JdPgVO6+zchM38x/e5jDNJ4PIhBGoOXvprf QEZAsu2YoZLWGp0ZxweCv+ERK+Z+DhPqaDeVx2RjmdzAZgcPWYdPaAwOmei3S89m J7mKgh66dUObA2f/D+RczMogf0Kjrhy1RhAHdv55e75TWNAk/Pr81F9CsA/tjyw= = Received: from nasanppmta02.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uvne4143q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 10 Dec 2023 08:55:57 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA02.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BA8tuEH022958 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 10 Dec 2023 08:55:56 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Sun, 10 Dec 2023 00:55:56 -0800 From: Andrew Pinski To: Subject: [PATCH] aarch64: Fix wrong code for bfloat when f16 is enabled [PR 111867] Date: Sun, 10 Dec 2023 00:55:46 -0800 Message-ID: <20231210085546.1531375-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01a.na.qualcomm.com (10.47.209.196) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 6GzN2iLZ2y1rGouK2l4nPrDGQOT3dDjV X-Proofpoint-ORIG-GUID: 6GzN2iLZ2y1rGouK2l4nPrDGQOT3dDjV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 bulkscore=0 spamscore=0 suspectscore=0 phishscore=0 priorityscore=1501 clxscore=1015 mlxlogscore=999 adultscore=0 lowpriorityscore=0 mlxscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312100076 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784884600847684482 X-GMAIL-MSGID: 1784884600847684482 The problem here is when f16 is enabled, movbf_aarch64 accepts `Ufc` as a constraint: [ w , Ufc ; fconsts , fp16 ] fmov\t%h0, %1 But that is for fmov values and in this case fmov represents f16 rather than bfloat16 values. This means we would get the wrong value in the register. Built and tested for aarch64-linux-gnu with no regressions. Also tested with `-march=armv9-a+sve2, gcc.dg/torture/bfloat16-basic.c and gcc.dg/torture/bfloat16-builtin.c no longer fail. gcc/ChangeLog: PR target/111867 * config/aarch64/aarch64.cc (aarch64_float_const_representable_p): For BFmode, only accept +0.0. Signed-off-by: Andrew Pinski --- gcc/config/aarch64/aarch64.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 5cffdabc62e..d48f5a1ba4b 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -23904,6 +23904,7 @@ aarch64_float_const_representable_p (rtx x) r = *CONST_DOUBLE_REAL_VALUE (x); + /* We cannot represent infinities, NaNs or +/-zero. We won't know if we have +zero until we analyse the mantissa, but we can reject the other invalid values. */ @@ -23911,6 +23912,10 @@ aarch64_float_const_representable_p (rtx x) || REAL_VALUE_MINUS_ZERO (r)) return false; + /* For BFmode, only handle 0.0. */ + if (GET_MODE (x) == BFmode) + return real_iszero (&r, false); + /* Extract exponent. */ r = real_value_abs (&r); exponent = REAL_EXP (&r);