public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops
@ 2020-08-18 22:34 vsevolod.livinskij at frtk dot ru
2020-08-25 10:58 ` [Bug tree-optimization/96693] [11 Regression] " rguenth at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: vsevolod.livinskij at frtk dot ru @ 2020-08-18 22:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96693
Bug ID: 96693
Summary: GCC produces incorrect code with -O2 for loops
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: vsevolod.livinskij at frtk dot ru
Target Milestone: ---
Error:
>$ g++ -O2 driver.cpp func.cpp && ./a.out
0
>$ g++ -O0 driver.cpp func.cpp && ./a.out
42
Reproducer:
//func.cpp
extern char var_20;
extern short var_22;
void test(unsigned a,
bool b,
long long p12[23]) {
for (int c = 0; c < 2;) {
if (b) {
for (int d = 0; d < 4082; d += 2)
for (int e = 0; e < a; e = 2)
var_20 = 0;
var_22 = 0;
}
c = p12[c];
}
}
//driver.cpp
#include <stdio.h>
unsigned int var_4 = 140810747U;
bool var_7 = (bool)0;
unsigned char var_20 = (unsigned char)82;
unsigned short var_22 = 42;
long long int arr_9 [23] ;
void test(unsigned int var_4, bool var_7, long long int arr_9 [23]);
int main() {
for (size_t i_0 = 0; i_0 < 23; ++i_0)
arr_9 [i_0] = -722784397873599555LL;
test(var_4, var_7, arr_9);
printf("%d\n", var_22);
}
GCC version:
11.0.0 20200816 (23747614cc8fc137c1f2ca64c8e224125a72fae5) + fix proposed in
bug 95396
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/96693] [11 Regression] GCC produces incorrect code with -O2 for loops
2020-08-18 22:34 [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops vsevolod.livinskij at frtk dot ru
@ 2020-08-25 10:58 ` rguenth at gcc dot gnu.org
2020-08-25 10:59 ` rguenth at gcc dot gnu.org
2020-08-25 12:47 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 10:58 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96693
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |11.0
Last reconfirmed| |2020-08-25
Summary|GCC produces incorrect code |[11 Regression] GCC
|with -O2 for loops |produces incorrect code
| |with -O2 for loops
Status|UNCONFIRMED |ASSIGNED
Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org
Ever confirmed|0 |1
--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. Looks like caused by my store-motion rewrite.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/96693] [11 Regression] GCC produces incorrect code with -O2 for loops
2020-08-18 22:34 [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops vsevolod.livinskij at frtk dot ru
2020-08-25 10:58 ` [Bug tree-optimization/96693] [11 Regression] " rguenth at gcc dot gnu.org
@ 2020-08-25 10:59 ` rguenth at gcc dot gnu.org
2020-08-25 12:47 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 10:59 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96693
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
unsigned int var_4 = 140810747U;
bool var_7 = (bool)0;
unsigned char var_20 = (unsigned char)82;
unsigned short var_22 = 42;
long long int arr_9 [23] ;
void __attribute__((noipa)) test(unsigned a, bool b, long long p12[23])
{
for (int c = 0; c < 2;) {
if (b) {
for (int d = 0; d < 4082; d += 2)
for (int e = 0; e < a; e = 2)
var_20 = 0;
var_22 = 0;
}
c = p12[c];
}
}
int main()
{
for (unsigned long i_0 = 0; i_0 < 23; ++i_0)
arr_9 [i_0] = -722784397873599555LL;
test(var_4, var_7, arr_9);
if (var_22 != 42)
__builtin_abort ();
}
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/96693] [11 Regression] GCC produces incorrect code with -O2 for loops
2020-08-18 22:34 [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops vsevolod.livinskij at frtk dot ru
2020-08-25 10:58 ` [Bug tree-optimization/96693] [11 Regression] " rguenth at gcc dot gnu.org
2020-08-25 10:59 ` rguenth at gcc dot gnu.org
@ 2020-08-25 12:47 ` rguenth at gcc dot gnu.org
2 siblings, 0 replies; 4+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-08-25 12:47 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96693
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |DUPLICATE
Status|ASSIGNED |RESOLVED
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Actually the same as PR96760, too.
*** This bug has been marked as a duplicate of bug 96760 ***
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-08-25 12:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-18 22:34 [Bug tree-optimization/96693] New: GCC produces incorrect code with -O2 for loops vsevolod.livinskij at frtk dot ru
2020-08-25 10:58 ` [Bug tree-optimization/96693] [11 Regression] " rguenth at gcc dot gnu.org
2020-08-25 10:59 ` rguenth at gcc dot gnu.org
2020-08-25 12:47 ` 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).