From patchwork Wed Nov 9 07:21:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Ruoyao X-Patchwork-Id: 1701645 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=ktPWTj+j; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4N6c063Z2Tz23lT for ; Wed, 9 Nov 2022 18:23:50 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 77BAD388B69A for ; Wed, 9 Nov 2022 07:23:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 77BAD388B69A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667978628; bh=RggD1Vm/Jdi0f7jbQ5OReSxaGHia3RrXeR/9/dOlaWc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ktPWTj+jgsLMMtZIk6Rk3quICbmVW0rLGMyppBv0PlT9fRsaUV7laMg6AZKAqNPCA 1aNTY0sWVLOTftICGQjpYaK7AgvWgz5oxPhuaiNK2kipoxa6HZnlB8u/uD5ETdmOEN DtjpzQA7AcQAGqCvDnJzjgACCzq+A7JHK44s18G0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from xry111.site (xry111.site [89.208.246.23]) by sourceware.org (Postfix) with ESMTPS id 1D4C83861C4D for ; Wed, 9 Nov 2022 07:22:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1D4C83861C4D Received: from xry111-x57s1.. (unknown [IPv6:240e:358:113a:1300:dc73:854d:832e:2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@xry111.site) by xry111.site (Postfix) with ESMTPSA id 05EA165DCC; Wed, 9 Nov 2022 02:22:31 -0500 (EST) To: gcc-patches@gcc.gnu.org Cc: Lulu Cheng , Wang Xuerui , Chenghua Xu , Xiaolin Tang , Xi Ruoyao Subject: [PATCH 1/4] LoongArch: Rename frint_ to rint2 Date: Wed, 9 Nov 2022 15:21:44 +0800 Message-Id: <20221109072147.789090-2-xry111@xry111.site> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221109072147.789090-1-xry111@xry111.site> References: <20221109072147.789090-1-xry111@xry111.site> MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FROM_SUSPICIOUS_NTLD, GIT_PATCH_0, KAM_NUMSUBJECT, KAM_SHORT, LIKELY_SPAM_FROM, PDS_OTHER_BAD_TLD, SPF_HELO_PASS, 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 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-Patchwork-Original-From: Xi Ruoyao via Gcc-patches From: Xi Ruoyao Reply-To: Xi Ruoyao Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" Use standard name so __builtin_rint{,f} can be expanded to one instruction. gcc/ChangeLog: * config/loongarch/loongarch.md (frint_): Rename to .. (rint2): .. this. gcc/testsuite/ChangeLog: * gcc.target/loongarch/frint.c: New test. --- gcc/config/loongarch/loongarch.md | 4 ++-- gcc/testsuite/gcc.target/loongarch/frint.c | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/frint.c diff --git a/gcc/config/loongarch/loongarch.md b/gcc/config/loongarch/loongarch.md index bda34d0f3db..a14ab14ac24 100644 --- a/gcc/config/loongarch/loongarch.md +++ b/gcc/config/loongarch/loongarch.md @@ -2012,8 +2012,8 @@ (define_insn "lui_h_hi12" [(set_attr "type" "move")] ) -;; Convert floating-point numbers to integers -(define_insn "frint_" +;; Round floating-point numbers to integers +(define_insn "rint2" [(set (match_operand:ANYF 0 "register_operand" "=f") (unspec:ANYF [(match_operand:ANYF 1 "register_operand" "f")] UNSPEC_FRINT))] diff --git a/gcc/testsuite/gcc.target/loongarch/frint.c b/gcc/testsuite/gcc.target/loongarch/frint.c new file mode 100644 index 00000000000..3ee6a8f973a --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/frint.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-mdouble-float" } */ +/* { dg-final { scan-assembler "frint\\.s" } } */ +/* { dg-final { scan-assembler "frint\\.d" } } */ + +double +my_rint (double a) +{ + return __builtin_rint (a); +} + +float +my_rintf (float a) +{ + return __builtin_rintf (a); +}