public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2
@ 2024-02-07 6:14 patrick at rivosinc dot com
2024-02-07 6:33 ` [Bug tree-optimization/113796] [14 Regression] " pinskia at gcc dot gnu.org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: patrick at rivosinc dot com @ 2024-02-07 6:14 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Bug ID: 113796
Summary: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: patrick at rivosinc dot com
Target Milestone: ---
Testcase:
signed char a[] = {0x80, 0};
int b;
signed char c;
int main() {
for (; b < 1; b += 1)
c = a[b] < 0 ?: a[b] >> 6;
if (c == 1)
return 0;
else
return 1;
}
Commands:
> /scratch/tc-testing/tc-feb-6/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O2 red.c -o user-config.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0,Zve32f=true,Zve64f=true /scratch/tc-testing/tc-feb-6/build-rv64gcv/bin/qemu-riscv64 user-config.out
> echo $?
1
> /scratch/tc-testing/tc-feb-6/build-rv64gcv/bin/riscv64-unknown-linux-gnu-gcc -march=rv64gcv -O1 red.c -o user-config.out
> QEMU_CPU=rv64,vlen=128,v=true,vext_spec=v1.0,Zve32f=true,Zve64f=true /scratch/tc-testing/tc-feb-6/build-rv64gcv/bin/qemu-riscv64 user-config.out
> echo $?
0
Godbolt:
https://godbolt.org/z/c7xrqx7Kz
Tested using r14-8834-gdb5c3f6d952 (not bisected).
Found using fuzzer.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] RISC-V rv64gcv vector: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
@ 2024-02-07 6:33 ` pinskia at gcc dot gnu.org
2024-02-07 6:35 ` pinskia at gcc dot gnu.org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 6:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=110252
Target Milestone|--- |14.0
Summary|[14] RISC-V rv64gcv vector: |[14 Regression] RISC-V
|Runtime mismatch at -O2 |rv64gcv vector: Runtime
| |mismatch at -O2
CC| |pinskia at gcc dot gnu.org
Component|target |tree-optimization
Last reconfirmed| |2024-02-07
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Confirmed, the issue is in ifcvt.
Before ifcvt we had:
```
if (_1 >= 0)
goto <bb 5>; [59.00%]
else
goto <bb 6>; [41.00%]
<bb 5> [local count: 563821836]:
iftmp.1_9 = _1 >> 6;
<bb 6> [local count: 955630226]:
# iftmp.1_5 = PHI <iftmp.1_9(5), 1(4)>
```
Which is fine.
Note the range for _1 is:
```
# RANGE [irange] signed char [0, 1]
iftmp.1_9 = _1 >> 6;
```
After ifcvt we get:
```
iftmp.1_9 = _1 >> 6;
_25 = _1 < 0;
_4 = (signed charD.14) _25;
# RANGE [irange] signed char [0, 1]
iftmp.1_5 = _4 | iftmp.1_9;
```
Which is incorrect.
ifcvt needs to something similar to what phiopt did in r14-2650-g8c79b49cd4fa74
.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] RISC-V rv64gcv vector: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
2024-02-07 6:33 ` [Bug tree-optimization/113796] [14 Regression] " pinskia at gcc dot gnu.org
@ 2024-02-07 6:35 ` pinskia at gcc dot gnu.org
2024-02-07 6:36 ` pinskia at gcc dot gnu.org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 6:35 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|riscv |riscv aarch64
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
It can be reproduce on aarch64 with `-O2 -fno-vect-cost-model
-march=armv9-a+sve` too so it is at least a regression there too.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] RISC-V rv64gcv vector: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
2024-02-07 6:33 ` [Bug tree-optimization/113796] [14 Regression] " pinskia at gcc dot gnu.org
2024-02-07 6:35 ` pinskia at gcc dot gnu.org
@ 2024-02-07 6:36 ` pinskia at gcc dot gnu.org
2024-02-07 6:48 ` pinskia at gcc dot gnu.org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 6:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Just an FYI :
[apinski@xeond2 upstream-full-cross]$ ./install/bin/aarch64-linux-gnu-gcc -O2
-static t65.c -march=armv9-a+sve2 -fno-vect-cost-model
[apinski@xeond2 upstream-full-cross]$ ./install-qemu/bin/qemu-aarch64 a.out
;echo $?
1
[apinski@xeond2 upstream-full-cross]$ ./install/bin/aarch64-linux-gnu-gcc -O2
-static t65.c -march=armv9-a+sve2
[apinski@xeond2 upstream-full-cross]$ ./install-qemu/bin/qemu-aarch64 a.out
;echo $?
0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] RISC-V rv64gcv vector: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (2 preceding siblings ...)
2024-02-07 6:36 ` pinskia at gcc dot gnu.org
@ 2024-02-07 6:48 ` pinskia at gcc dot gnu.org
2024-02-07 6:56 ` [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: " pinskia at gcc dot gnu.org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 6:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> ifcvt needs to something similar to what phiopt did in
> r14-2650-g8c79b49cd4fa74 .
Or ifcvt needs to remove the range info earlier ...
I have not looked into the ifcvt code to see which is the right approach.
But it was introduced by the same commit that introduced PR 110252 (which was
then fixed by the phiopt patch).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (3 preceding siblings ...)
2024-02-07 6:48 ` pinskia at gcc dot gnu.org
@ 2024-02-07 6:56 ` pinskia at gcc dot gnu.org
2024-02-07 8:53 ` rguenth at gcc dot gnu.org
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-02-07 6:56 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target|riscv aarch64 |
Summary|[14 Regression] RISC-V |[14 Regression] ifcvt does
|rv64gcv vector: Runtime |not remove range info
|mismatch at -O2 |before folding: Runtime
| |mismatch at -O2
--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Here is one that fails on x86_64 too:
```
signed char a[] = {0x80, 0x80,0x80,0x80};
int b;
signed char c;
int main() {
for (; b < sizeof(a); b += 1)
c = a[b] < 0 ?: a[b] >> 6;
if (c == 1)
return 0;
else
return 1;
}
```
Compile with `-O2 -fno-vect-cost-model` to see the issue.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (4 preceding siblings ...)
2024-02-07 6:56 ` [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: " pinskia at gcc dot gnu.org
@ 2024-02-07 8:53 ` rguenth at gcc dot gnu.org
2024-02-07 12:06 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-07 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Status|NEW |ASSIGNED
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Let me take this.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (5 preceding siblings ...)
2024-02-07 8:53 ` rguenth at gcc dot gnu.org
@ 2024-02-07 12:06 ` rguenth at gcc dot gnu.org
2024-02-07 14:50 ` cvs-commit at gcc dot gnu.org
2024-02-07 14:50 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-07 12:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
--- Comment #7 from Richard Biener <rguenth at gcc dot gnu.org> ---
We're removing flow-sensitive info in combine_blocks, but after inserting
and folding stmts comprising the PHI replacements. There's possibly
latent issues when building up the predicates themselves since that uses
maybe_fold_or_comparisons without the workaround added for if-combine.
I have a patch resetting flow-sensitive info earlier (and also covering
PHIs).
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (6 preceding siblings ...)
2024-02-07 12:06 ` rguenth at gcc dot gnu.org
@ 2024-02-07 14:50 ` cvs-commit at gcc dot gnu.org
2024-02-07 14:50 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-02-07 14:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
--- Comment #8 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:8636c538b68068cd2a4115fece531dc3e3e3a84a
commit r14-8869-g8636c538b68068cd2a4115fece531dc3e3e3a84a
Author: Richard Biener <rguenther@suse.de>
Date: Wed Feb 7 13:08:43 2024 +0100
tree-optimization/113796 - if-conversion and ranges
The following makes sure to wipe range info before folding the
COND_EXPRs we insert as part of replacing PHI nodes when combining
blocks in the if-conversion pass.
PR tree-optimization/113796
* tree-if-conv.cc (combine_blocks): Wipe range-info before
replacing PHIs and inserting predicates.
* gcc.dg/torture/pr113796.c: New testcase.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: Runtime mismatch at -O2
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
` (7 preceding siblings ...)
2024-02-07 14:50 ` cvs-commit at gcc dot gnu.org
@ 2024-02-07 14:50 ` rguenth at gcc dot gnu.org
8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2024-02-07 14:50 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113796
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed (but possibly latent on branches of course).
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2024-02-07 14:50 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-07 6:14 [Bug target/113796] New: [14] RISC-V rv64gcv vector: Runtime mismatch at -O2 patrick at rivosinc dot com
2024-02-07 6:33 ` [Bug tree-optimization/113796] [14 Regression] " pinskia at gcc dot gnu.org
2024-02-07 6:35 ` pinskia at gcc dot gnu.org
2024-02-07 6:36 ` pinskia at gcc dot gnu.org
2024-02-07 6:48 ` pinskia at gcc dot gnu.org
2024-02-07 6:56 ` [Bug tree-optimization/113796] [14 Regression] ifcvt does not remove range info before folding: " pinskia at gcc dot gnu.org
2024-02-07 8:53 ` rguenth at gcc dot gnu.org
2024-02-07 12:06 ` rguenth at gcc dot gnu.org
2024-02-07 14:50 ` cvs-commit at gcc dot gnu.org
2024-02-07 14:50 ` rguenth at gcc dot gnu.org
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).