From: Jeff Law <jeffreyalaw@gmail.com>
To: Richard Biener <richard.guenther@gmail.com>, pan2.li@intel.com
Cc: gcc-patches@gcc.gnu.org, juzhe.zhong@rivai.ai,
yanzhang.wang@intel.com, kito.cheng@gmail.com
Subject: Re: [PATCH v3] RISC-V: Bugfix for doesn't honor no-signed-zeros option
Date: Tue, 9 Jan 2024 10:46:16 -0700 [thread overview]
Message-ID: <e4cb4dd7-582d-4201-ae85-c4c8c2368299@gmail.com> (raw)
In-Reply-To: <CAFiYyc1Uw99w7SXTaM_oyGzVCVqd3vZD89-yF0Fe-7vCKvVmWQ@mail.gmail.com>
On 1/8/24 03:45, Richard Biener wrote:
> On Tue, Jan 2, 2024 at 2:37 PM <pan2.li@intel.com> wrote:
>>
>> From: Pan Li <pan2.li@intel.com>
>>
>> According to the sematics of no-signed-zeros option, the backend
>> like RISC-V should treat the minus zero -0.0f as plus zero 0.0f.
>>
>> Consider below example with option -fno-signed-zeros.
>>
>> void
>> test (float *a)
>> {
>> *a = -0.0;
>> }
>>
>> We will generate code as below, which doesn't treat the minus zero
>> as plus zero.
>>
>> test:
>> lui a5,%hi(.LC0)
>> flw fa5,%lo(.LC0)(a5)
>> fsw fa5,0(a0)
>> ret
>>
>> .LC0:
>> .word -2147483648 // aka -0.0 (0x80000000 in hex)
>>
>> This patch would like to fix the bug and treat the minus zero -0.0
>> as plus zero, aka +0.0. Thus after this patch we will have asm code
>> as below for the above sampe code.
>>
>> test:
>> sw zero,0(a0)
>> ret
>>
>> This patch also fix the run failure of the test case pr30957-1.c. The
>> below tests are passed for this patch.
>
> We don't really expect targets to do this. The small testcase above
> is somewhat ill-formed with -fno-signed-zeros. Note there's no
> -0.0 in pr30957-1.c so why does that one fail for you? Does
> the -fvariable-expansion-in-unroller code maybe not trigger for
> riscv?
Loop unrolling (and thus variable expansion) doesn't trigger on the VLA
style architectures. aarch64 passes becuase its backend knows it can
translate -0.0 into 0.0.
While we don't require that from ports, I'd just assume do the
optimization similar to aarch64 rather than xfail or skip the test on
RISC-V. We can load 0.0 more efficiently than -0.0.
>
> I think we should go to PR30957 and see what that was filed originally
> for, the testcase doesn't make much sense to me.
It's got more history than I'd like :(
jeff
next prev parent reply other threads:[~2024-01-09 17:46 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-23 11:07 [PATCH v1] RISC-V: XFAIL pr30957-1.c when loop vectorized with variable factor pan2.li
2023-12-23 17:19 ` Jeff Law
2023-12-24 2:01 ` Li, Pan2
2023-12-26 9:34 ` [PATCH v2] " pan2.li
2023-12-28 16:39 ` Jeff Law
2023-12-29 0:42 ` Li, Pan2
2023-12-29 1:03 ` Jeff Law
2023-12-29 5:56 ` Li, Pan2
2023-12-30 3:13 ` Jeff Law
2024-01-01 8:56 ` Li, Pan2
2024-01-02 11:55 ` [PATCH v3] RISC-V: Bugfix for doesn't honor no-signed-zeros option pan2.li
2024-01-08 10:45 ` Richard Biener
2024-01-09 1:22 ` Li, Pan2
2024-01-09 7:17 ` Li, Pan2
2024-01-09 13:08 ` Richard Biener
2024-01-09 17:46 ` Jeff Law [this message]
2024-01-10 4:28 ` Li, Pan2
2024-01-11 1:38 ` [PATCH v4] LOOP-UNROLL: Leverage HAS_SIGNED_ZERO for var expansion pan2.li
2024-01-11 8:33 ` Richard Biener
2024-01-11 8:48 ` Li, Pan2
2024-01-11 8:50 ` [PATCH v5] " pan2.li
2024-01-11 9:21 ` Richard Biener
2024-01-11 10:35 ` Li, Pan2
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e4cb4dd7-582d-4201-ae85-c4c8c2368299@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=juzhe.zhong@rivai.ai \
--cc=kito.cheng@gmail.com \
--cc=pan2.li@intel.com \
--cc=richard.guenther@gmail.com \
--cc=yanzhang.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).