From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id BF1083858CD1 for ; Thu, 23 Nov 2023 06:35:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF1083858CD1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF1083858CD1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700721330; cv=none; b=eDr9eZOUErbyp04DktgfEh3QH5FY5sFSWYXpOzHJq9sn3ckmxbcWhQsxF0Bh+IK3pfe1+B4GXElFdkehHQxzEgXf7MzuLfl9p7QD9AnnawlsIZf9Rd8ScHBphsbJVB2+YxJqU4wSrDoyOT7NsJWOaqrcN1tkBKd438ylFb6UTXU= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700721330; c=relaxed/simple; bh=KHGWvcWyw1W16Vk43DNEKF4jsUj+mdMGnCblvwfn2/U=; h=Subject:To:From:Message-ID:Date:MIME-Version; b=cuolrgtxxwjyzaoD1i+AjmPp+wxn3t17aNMCsDGYzm+37HD7ANdk/P1TvnU8qJYGIKgx1l1XCUejdOnf8fGkqKtqsagLZ7Tw3+r35LgpVyqmEmNDZvqMbMmhvLYFFnUUfas6046P9V7HzDJWGS8Z3b89gDb4f5zBaXKdhGwi1fw= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.20.4.107]) by gateway (Coremail) with SMTP id _____8Dxg_Cr8l5lTjQ8AA--.54033S3; Thu, 23 Nov 2023 14:35:23 +0800 (CST) Received: from [10.20.4.107] (unknown [10.20.4.107]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxO9yn8l5lRWlKAA--.32507S3; Thu, 23 Nov 2023 14:35:21 +0800 (CST) Subject: Re: [PATCH v3 1/5] LoongArch: Fix usage of LSX and LASX frint/ftint instructions [PR112578] To: Xi Ruoyao , gcc-patches@gcc.gnu.org Cc: i@xen0n.name, xuchenghua@loongson.cn References: <20231120004728.205167-1-xry111@xry111.site> <20231120004728.205167-2-xry111@xry111.site> From: chenglulu Message-ID: Date: Thu, 23 Nov 2023 14:35:19 +0800 User-Agent: Mozilla/5.0 (X11; Linux loongarch64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20231120004728.205167-2-xry111@xry111.site> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-CM-TRANSID:AQAAf8CxO9yn8l5lRWlKAA--.32507S3 X-CM-SenderInfo: xfkh0wpoxo3qxorr0wxvrqhubq/ X-Coremail-Antispam: 1Uk129KBj93XoW7AF4kCw48tF13Jr1ktFy5GFX_yoW8Cw48pr 43G34rCFW5Ars29w18Ca1Syry3G3yrGFWUJFyUW3y7trZ0qwn7tayFkrWY9F9xKw1rKF10 vF45Kw1kuFW5AagCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUv2b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1j6r18McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IY64vIr41lc7I2V7IY0VAS07 AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02 F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw 1lIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCwCI42IY6xIIjxv20xvEc7Cj xVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r 1j6r4UMIIF0xvEx4A2jsIEc7CjxVAFwI0_Jr0_GrUvcSsGvfC2KfnxnUUI43ZEXa7IU8cz VUUUUUU== X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,NICE_REPLY_A,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 List-Id: 在 2023/11/20 上午8:47, Xi Ruoyao 写道: > The usage LSX and LASX frint/ftint instructions had some problems: > > 1. These instructions raises FE_INEXACT, which is not allowed with > -fno-fp-int-builtin-inexact for most C2x section F.10.6 functions > (the only exceptions are rint, lrint, and llrint). > 2. The "frint" instruction without explicit rounding mode is used for > roundM2, this is incorrect because roundM2 is defined "rounding > operand 1 to the *nearest* integer, rounding away from zero in the > event of a tie". We actually don't have such an instruction. Our > frintrne instruction is roundevenM2 (unfortunately, this is not > documented). > 3. These define_insn's are written in a way not so easy to hack. > > So I removed these instructions and created a "simd.md" file, then added > them and the corresponding expanders there. The advantage of the > simd.md file is we don't need to duplicate the RTL template twice (in > lsx.md and lasx.md). /* snip */ > +;; fix_trunc is allowed to raise inexact exception even if > +;; -fno-fp-int-builtin-inexact. Because the middle end trys to match > +;; (FIX x) and it does not know (FIX (UNSPEC_SIMD_FRINTRZ x)), we need > +;; to use define_insn_and_split instead of define_expand (expanders are > +;; not considered during matching). Hi,  I don’t quite understand this part. Is it because define_insn would be duplicated with the above implementation, so define_insn_and_split is used? Thanks. > +(define_insn_and_split "fix_trunc2" > + [(set (match_operand: 0 "register_operand" "=f") > + (fix: (match_operand:FVEC 1 "register_operand" "f")))] > + "" > + "#" > + "" > + [(const_int 0)] > + { > + emit_insn (gen__vftintrz__ ( > + operands[0], operands[1])); > + DONE; > + } > + [(set_attr "type" "simd_fcvt") > + (set_attr "mode" "")])