Ok, thanks for the advice. I have modified __builtin_nanq("") and
__builtin_nansq("") in gcc according to the functionality of the function, and
the implementation is shown in the following code.
>>>
__float128 __nanq (const char * str)
{
union _FP_UNION_Q nan;
nan.bits.frac0 = 0;
nan.bits.frac1 = 0;
nan.bits.exp = 0x7FFF;
nan.bits.sign = 0;
return nan.flt;
}
__float128 __nansq (const char *str)
{
union _FP_UNION_Q nan;
nan.bits.frac0 = 0xFFFFFFFFFFFFFFFFUL;
nan.bits.frac1 = 0x0000FFFFFFFFFFFFUL;
nan.bits.exp = 0x7FFF;
nan.bits.sign = 0;
return nan.flt;
}
-----
> -----原始邮件-----
> 发件人: "Xi Ruoyao" <[email protected]>
> 发送时间:2023-08-08 10:24:39 (星期二)
> 收件人: chenxiaolong <[email protected]>, [email protected]
> 抄送: [email protected], [email protected], [email protected]
> 主题: Re: [PATCH v2] LoongArch:Implement 128-bit floating point functions in
> gcc.
>
> On Tue, 2023-08-08 at 10:09 +0800, chenxiaolong wrote:
> > +/* Count the number of functions with "q" as the suffix. */
> > +const int MATHQ_NUMS=(int)LARCH_MAX_FTYPE_MAX-(int)LARCH_BUILTIN_HUGE_VALQ;
>
> Format issue still not fixed.
>
> > +__float128 nanq (const char * str)
> > +{
> > + union _FP_UNION_Q nan;
> > + nan.bits.frac0 = 0;
> > + nan.bits.frac1 = 0;
> > + nan.bits.exp = 0x7FFF;
> > + nan.bits.sign = 1;
> > + if (str != NULL && strlen (str) > 0)
> > + return nan.flt;
> > + return 0;
> > +}
>
> I don't think the logic is correct. __builtin_nanq("") should return a
> NaN, not 0.
>
> > + if (str != NULL && strlen (str) > 0)
> > + return nan.flt;
>
> Indent is 2, not 4.
>
> And we don't need to check "str != NULL" here. Calling nan()-family
> functions with a null tagp is deemed undefined behavior.
>
> > +__float128 nansq (const char *str)
> > +{
> > + union _FP_UNION_Q nan;
> > + nan.bits.frac0 = 0;
> > + nan.bits.frac1 = 0;
> > + nan.bits.exp = 0x7FFF;
> > + nan.bits.sign = 1;
> > + if (str != NULL && strlen (str) > 0)
> > + return nan.flt;
> > + return 0;
> > +}
>
> Same logic error. And this seems exactly same as nanq, the analogous is
> definitely wrong because __builtin_nanq should return a quiet NaN, but
> __builtin_nansq should return a signaling NaN.
>
> --
> Xi Ruoyao <[email protected]>
> School of Aerospace Science and Technology, Xidian University
本邮件及其附件含有龙芯中科的商业秘密信息,仅限于发送给上面地址中列出的个人或群组。禁止任何其他人以任何形式使用(包括但不限于全部或部分地泄露、复制或散发)本邮件及其附件中的信息。如果您错收本邮件,请您立即电话或邮件通知发件人并删除本邮件。
This email and its attachments contain confidential information from Loongson
Technology , which is intended only for the person or entity whose address is
listed above. Any use of the information contained herein in any way
(including, but not limited to, total or partial disclosure, reproduction or
dissemination) by persons other than the intended recipient(s) is prohibited.
If you receive this email in error, please notify the sender by phone or email
immediately and delete it.