public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2
@ 2023-03-30 7:12 vsevolod.livinskiy at gmail dot com
2023-03-30 7:26 ` [Bug tree-optimization/109342] " rguenth at gcc dot gnu.org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: vsevolod.livinskiy at gmail dot com @ 2023-03-30 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
Bug ID: 109342
Summary: [13 Regression] Wrong code with -O2
Product: gcc
Version: 13.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vsevolod.livinskiy at gmail dot com
Target Milestone: ---
Link to the Compiler Explorer: https://godbolt.org/z/zKqcna3vn
Reproducer:
#include <stdio.h>
unsigned long long int var_4 = 42;
unsigned long long int var_14 = 10;
unsigned char var_16 = 1;
unsigned short var_18 = 0;
short var_75;
inline const int &foo(const int &b, const int &c) { return b < c ? c : b; }
inline unsigned long long &bar(unsigned long long &b, unsigned long long &c) {
return !c ? c : b;
}
void test(unsigned long long var_4, unsigned long long var_14,
unsigned char var_16, unsigned short var_18) __attribute__((noipa));
void test(unsigned long long var_4, unsigned long long var_14,
unsigned char var_16, unsigned short var_18) {
for (bool h = 0; h < (bool)foo(var_16 ? -7 : 4, var_4 ? var_4 : var_18);
h = 2)
var_75 = bar(var_4, var_14);
}
int main() {
test(var_4, var_14, var_16, var_18);
printf("%hd\n", var_75);
if (var_75 != 42)
__builtin_abort();
}
Error:
>$ g++ -O0 small.cpp && ./a.out
42
>$ g++ -O2 small.cpp && ./a.out
0
Aborted (core dumped)
gcc version 13.0.1 20230329 (3be4e43a6a0f429648ea188c8e110b74268fed27)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
@ 2023-03-30 7:26 ` rguenth at gcc dot gnu.org
2023-03-30 7:41 ` [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80 marxin at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-30 7:26 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |needs-bisection
Priority|P3 |P1
Known to work| |12.2.1
Target Milestone|--- |13.0
Status|UNCONFIRMED |NEW
Last reconfirmed| |2023-03-30
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
2023-03-30 7:26 ` [Bug tree-optimization/109342] " rguenth at gcc dot gnu.org
@ 2023-03-30 7:41 ` marxin at gcc dot gnu.org
2023-03-30 7:45 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: marxin at gcc dot gnu.org @ 2023-03-30 7:41 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org
Keywords|needs-bisection |
Summary|[13 Regression] Wrong code |[13 Regression] Wrong code
|with -O2 |with -O2 since
| |r13-5348-gc29d85359add80
--- Comment #2 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-5348-gc29d85359add80.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
2023-03-30 7:26 ` [Bug tree-optimization/109342] " rguenth at gcc dot gnu.org
2023-03-30 7:41 ` [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80 marxin at gcc dot gnu.org
@ 2023-03-30 7:45 ` rguenth at gcc dot gnu.org
2023-03-30 11:02 ` cvs-commit at gcc dot gnu.org
2023-03-30 11:02 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-30 7:45 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine then.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
` (2 preceding siblings ...)
2023-03-30 7:45 ` rguenth at gcc dot gnu.org
@ 2023-03-30 11:02 ` cvs-commit at gcc dot gnu.org
2023-03-30 11:02 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-03-30 11:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
--- Comment #4 from CVS 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:1d0ba4467dd9cad11eb9ff547442e3ce6292b892
commit r13-6942-g1d0ba4467dd9cad11eb9ff547442e3ce6292b892
Author: Richard Biener <rguenther@suse.de>
Date: Thu Mar 30 11:32:19 2023 +0200
tree-optimization/109342 - wrong code with edge equivalences in VN
The following testcase shows a problem in how we query valitity for
equivalences on edges when the edge is a backedge and thus refering
to a block thats later in the iteration order we use for VN. That
causes the dominated_by_p_w_unex helper to look at edge executable
state that's not yet computed and thus still at optimistic not
executable state.
The following makes sure to use a plain dominance check in these cases.
PR tree-optimization/109342
* tree-ssa-sccvn.cc (vn_nary_op_get_predicated_value): New
overload for edge. When that edge is a backedge use
dominated_by_p directly.
* g++.dg/torture/pr109342.C: New testcase.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
` (3 preceding siblings ...)
2023-03-30 11:02 ` cvs-commit at gcc dot gnu.org
@ 2023-03-30 11:02 ` rguenth at gcc dot gnu.org
4 siblings, 0 replies; 6+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-03-30 11:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109342
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-03-30 11:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-30 7:12 [Bug tree-optimization/109342] New: [13 Regression] Wrong code with -O2 vsevolod.livinskiy at gmail dot com
2023-03-30 7:26 ` [Bug tree-optimization/109342] " rguenth at gcc dot gnu.org
2023-03-30 7:41 ` [Bug tree-optimization/109342] [13 Regression] Wrong code with -O2 since r13-5348-gc29d85359add80 marxin at gcc dot gnu.org
2023-03-30 7:45 ` rguenth at gcc dot gnu.org
2023-03-30 11:02 ` cvs-commit at gcc dot gnu.org
2023-03-30 11:02 ` 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).