public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation
@ 2020-07-09 11:38 heckflosse67 at gmx dot de
2020-07-09 12:01 ` [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77 marxin at gcc dot gnu.org
` (12 more replies)
0 siblings, 13 replies; 14+ messages in thread
From: heckflosse67 at gmx dot de @ 2020-07-09 11:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
Bug ID: 96133
Summary: x86-64 gcc 10.1 using -O3 leads to wrong calculation
Product: gcc
Version: 10.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: heckflosse67 at gmx dot de
Target Milestone: ---
Here's a simple example which works fine in gcc up to version 9 when build
using -O3
On gcc 10 -O3, the output is different to the output of gcc 10 -O2.
The output of gcc 10 -O2 is the same as of gcc 9.3 -O3 and gcc 9.3 -O2
Using gcc 10 -O3 -fno-tree-loop-vectorize it also works fine.
```
#include <iostream>
constexpr double xyz_sRGB[3][3] = {
{0.4360747, 0.3850649, 0.1430804},
{0.2225045, 0.7168786, 0.0606169},
{0.0139322, 0.0971045, 0.7141733}
};
int main() {
double rgb_cam[3][3] = {{1.0, 2.0, 3.0}, {4.0, 5.0, 6.0}, {7.0, 8.0, 9.0}};
double xyz_cam[3][3] = {{0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}, {0.0, 0.0, 0.0}};
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++)
for (int k = 0; k < 3; k++) {
xyz_cam[i][j] += xyz_sRGB[i][k] * rgb_cam[k][j];
}
for (int i = 0; i < 3; i++)
for (int j = 0; j < 3; j++) {
std::cout << xyz_cam[i][j] << std::endl;
}
return 0;
}
```
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
@ 2020-07-09 12:01 ` marxin at gcc dot gnu.org
2020-07-09 12:06 ` rguenth at gcc dot gnu.org
` (11 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: marxin at gcc dot gnu.org @ 2020-07-09 12:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |marxin at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Status|UNCONFIRMED |NEW
Summary|x86-64 gcc 10.1 using -O3 |[10/11 Regression] x86-64
|leads to wrong calculation |gcc 10.1 using -O3 leads to
| |wrong calculation since
| |r10-1882-g831e688af50c5f77
Ever confirmed|0 |1
Last reconfirmed| |2020-07-09
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r10-1882-g831e688af50c5f77.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
2020-07-09 12:01 ` [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77 marxin at gcc dot gnu.org
@ 2020-07-09 12:06 ` rguenth at gcc dot gnu.org
2020-07-09 12:06 ` [Bug tree-optimization/96133] " rguenth at gcc dot gnu.org
` (10 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-09 12:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Confirmed. The i == 1 lane is different. We're using standard interleaving
vectorization here, the innermost two loops are unrolled and rgb_cam is elided.
Note eventually we optimize the whole loop at compile-time to
<bb 2> [local count: 89478486]:
MEM <vector(2) double> [(double *)&xyz_cam] = {
2.97789709999999985257090884260833263397216796875e+0,
3.94211709999999992959374139900319278240203857421875e+0 };
MEM <vector(2) double> [(double *)&xyz_cam + 16B] = {
4.9063371000000000066165739553980529308319091796875e+0,
3.291832700000000055950977184693329036235809326171875e+0 };
MEM <vector(2) double> [(double *)&xyz_cam + 32B] = {
4.06932820000000017301999832852743566036224365234375e+0,
4.8468236999999998459998096222989261150360107421875e+0 };
MEM <vector(2) double> [(double *)&xyz_cam + 48B] = {
5.40156330000000028945805752300657331943511962890625e+0,
6.2267732999999996224005371914245188236236572265625e+0 };
xyz_cam[2][2] = 7.051983299999999843521436559967696666717529296875e+0;
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
2020-07-09 12:01 ` [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77 marxin at gcc dot gnu.org
2020-07-09 12:06 ` rguenth at gcc dot gnu.org
@ 2020-07-09 12:06 ` rguenth at gcc dot gnu.org
2020-07-09 12:13 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-09 12:06 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|--- |10.2
Component|c++ |tree-optimization
Keywords| |wrong-code
Priority|P3 |P2
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (2 preceding siblings ...)
2020-07-09 12:06 ` [Bug tree-optimization/96133] " rguenth at gcc dot gnu.org
@ 2020-07-09 12:13 ` rguenth at gcc dot gnu.org
2020-07-09 12:18 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-09 12:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
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> ---
Value numbering stmt = vect__68.15_89 = MEM <vector(2) double> [(double
*)vectp_xyz_sRGB.12_85];
RHS MEM <vector(2) double> [(double *)vectp_xyz_sRGB.12_85] simplified to {
1.4308039999999999647428694515838287770748138427734375e-1, 0.0 }
Setting value number of vect__68.15_89 to {
1.4308039999999999647428694515838287770748138427734375e-1, 0.0 } (changed)
I guess we might be confused by the read crossing CTORs.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (3 preceding siblings ...)
2020-07-09 12:13 ` rguenth at gcc dot gnu.org
@ 2020-07-09 12:18 ` rguenth at gcc dot gnu.org
2020-07-09 17:54 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-09 12:18 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Interestingly it works for int[4] but fails for int[2].
typedef int T;
static const T a[2][3] = { { 1, 2, 3 }, { 4, 5, 6 } };
typedef T v2 __attribute__((vector_size(2*sizeof(T))));
int
main()
{
const T *p = &a[0][2];
v2 x = *(const v2 *)p;
T z = x[1];
if (z != 4)
__builtin_abort ();
return 0;
}
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (4 preceding siblings ...)
2020-07-09 12:18 ` rguenth at gcc dot gnu.org
@ 2020-07-09 17:54 ` cvs-commit at gcc dot gnu.org
2020-07-09 17:55 ` rguenth at gcc dot gnu.org
` (6 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-09 17:54 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #5 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:9ddea9306251b7d4e4fd1d67a5941ef7448b2e66
commit r11-1972-g9ddea9306251b7d4e4fd1d67a5941ef7448b2e66
Author: Richard Biener <rguenther@suse.de>
Date: Thu Jul 9 16:06:04 2020 +0200
fixup BIT_FIELD_REF detection in SLP discovery
This fixes a thinko where we end up combining a BIT_FIELD_REF
and a memory access, fixed by checking all stmts are a load or
none.
2020-07-09 Richard Biener <rguenther@suse.de>
PR tree-optimization/96133
* tree-vect-slp.c (vect_build_slp_tree_1): Compare load_p
status between stmts.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (5 preceding siblings ...)
2020-07-09 17:54 ` cvs-commit at gcc dot gnu.org
@ 2020-07-09 17:55 ` rguenth at gcc dot gnu.org
2020-07-09 19:33 ` heckflosse67 at gmx dot de
` (5 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-09 17:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to CVS Commits from comment #5)
> The master branch has been updated by Richard Biener <rguenth@gcc.gnu.org>:
>
> https://gcc.gnu.org/g:9ddea9306251b7d4e4fd1d67a5941ef7448b2e66
>
> commit r11-1972-g9ddea9306251b7d4e4fd1d67a5941ef7448b2e66
> Author: Richard Biener <rguenther@suse.de>
> Date: Thu Jul 9 16:06:04 2020 +0200
>
> fixup BIT_FIELD_REF detection in SLP discovery
>
> This fixes a thinko where we end up combining a BIT_FIELD_REF
> and a memory access, fixed by checking all stmts are a load or
> none.
>
> 2020-07-09 Richard Biener <rguenther@suse.de>
>
> PR tree-optimization/96133
> * tree-vect-slp.c (vect_build_slp_tree_1): Compare load_p
> status between stmts.
Whoops - this was for PR96134.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (6 preceding siblings ...)
2020-07-09 17:55 ` rguenth at gcc dot gnu.org
@ 2020-07-09 19:33 ` heckflosse67 at gmx dot de
2020-07-10 7:30 ` rguenth at gcc dot gnu.org
` (4 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: heckflosse67 at gmx dot de @ 2020-07-09 19:33 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #7 from Ingo Weyrich <heckflosse67 at gmx dot de> ---
Richard, does you last comment mean, you already fixed it?. How can I test?
Maybe using godbolt?
Ingo
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (7 preceding siblings ...)
2020-07-09 19:33 ` heckflosse67 at gmx dot de
@ 2020-07-10 7:30 ` rguenth at gcc dot gnu.org
2020-07-10 8:53 ` cvs-commit at gcc dot gnu.org
` (3 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-10 7:30 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Ingo Weyrich from comment #7)
> Richard, does you last comment mean, you already fixed it?. How can I test?
> Maybe using godbolt?
>
> Ingo
Sorry, no - a test is still in development, the last comment meant I mistyped
the bug number in an unrelated commit ;)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (8 preceding siblings ...)
2020-07-10 7:30 ` rguenth at gcc dot gnu.org
@ 2020-07-10 8:53 ` cvs-commit at gcc dot gnu.org
2020-07-10 10:38 ` [Bug tree-optimization/96133] [10 " cvs-commit at gcc dot gnu.org
` (2 subsequent siblings)
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-10 8:53 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #9 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:6e41c27bf549d957eb399d39d7d0c213f8733351
commit r11-1981-g6e41c27bf549d957eb399d39d7d0c213f8733351
Author: Richard Biener <rguenther@suse.de>
Date: Thu Jul 9 16:03:45 2020 +0200
fix constant folding from array CTORs
This fixes the case where we try to fold a read from an
array initalizer and happen to cross the boundary of
multiple CTORs which isn't really supported. For the
interesting cases like the testcase we actually handle
the folding by encoding the whole initializer.
2020-07-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/96133
* gimple-fold.c (fold_array_ctor_reference): Do not
recurse to folding a CTOR that does not fully cover the
asked for object.
* gcc.dg/torture/pr96133.c: New testcase.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (9 preceding siblings ...)
2020-07-10 8:53 ` cvs-commit at gcc dot gnu.org
@ 2020-07-10 10:38 ` cvs-commit at gcc dot gnu.org
2020-07-10 10:38 ` rguenth at gcc dot gnu.org
2020-07-10 11:36 ` heckflosse67 at gmx dot de
12 siblings, 0 replies; 14+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-07-10 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-10 branch has been updated by Richard Biener
<rguenth@gcc.gnu.org>:
https://gcc.gnu.org/g:8614106f121db118f9db260b9949883485d0bbf6
commit r10-8455-g8614106f121db118f9db260b9949883485d0bbf6
Author: Richard Biener <rguenther@suse.de>
Date: Thu Jul 9 16:03:45 2020 +0200
fix constant folding from array CTORs
This fixes the case where we try to fold a read from an
array initalizer and happen to cross the boundary of
multiple CTORs which isn't really supported. For the
interesting cases like the testcase we actually handle
the folding by encoding the whole initializer.
2020-07-10 Richard Biener <rguenther@suse.de>
PR tree-optimization/96133
* gimple-fold.c (fold_array_ctor_reference): Do not
recurse to folding a CTOR that does not fully cover the
asked for object.
* gcc.dg/torture/pr96133.c: New testcase.
(cherry picked from commit 6e41c27bf549d957eb399d39d7d0c213f8733351)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (10 preceding siblings ...)
2020-07-10 10:38 ` [Bug tree-optimization/96133] [10 " cvs-commit at gcc dot gnu.org
@ 2020-07-10 10:38 ` rguenth at gcc dot gnu.org
2020-07-10 11:36 ` heckflosse67 at gmx dot de
12 siblings, 0 replies; 14+ messages in thread
From: rguenth at gcc dot gnu.org @ 2020-07-10 10:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Known to work| |10.1.1
Status|ASSIGNED |RESOLVED
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.
^ permalink raw reply [flat|nested] 14+ messages in thread
* [Bug tree-optimization/96133] [10 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
` (11 preceding siblings ...)
2020-07-10 10:38 ` rguenth at gcc dot gnu.org
@ 2020-07-10 11:36 ` heckflosse67 at gmx dot de
12 siblings, 0 replies; 14+ messages in thread
From: heckflosse67 at gmx dot de @ 2020-07-10 11:36 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96133
--- Comment #12 from Ingo Weyrich <heckflosse67 at gmx dot de> ---
Thanks for fixing and kudos for your very fast response time!
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2020-07-10 11:36 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-09 11:38 [Bug c++/96133] New: x86-64 gcc 10.1 using -O3 leads to wrong calculation heckflosse67 at gmx dot de
2020-07-09 12:01 ` [Bug c++/96133] [10/11 Regression] x86-64 gcc 10.1 using -O3 leads to wrong calculation since r10-1882-g831e688af50c5f77 marxin at gcc dot gnu.org
2020-07-09 12:06 ` rguenth at gcc dot gnu.org
2020-07-09 12:06 ` [Bug tree-optimization/96133] " rguenth at gcc dot gnu.org
2020-07-09 12:13 ` rguenth at gcc dot gnu.org
2020-07-09 12:18 ` rguenth at gcc dot gnu.org
2020-07-09 17:54 ` cvs-commit at gcc dot gnu.org
2020-07-09 17:55 ` rguenth at gcc dot gnu.org
2020-07-09 19:33 ` heckflosse67 at gmx dot de
2020-07-10 7:30 ` rguenth at gcc dot gnu.org
2020-07-10 8:53 ` cvs-commit at gcc dot gnu.org
2020-07-10 10:38 ` [Bug tree-optimization/96133] [10 " cvs-commit at gcc dot gnu.org
2020-07-10 10:38 ` rguenth at gcc dot gnu.org
2020-07-10 11:36 ` heckflosse67 at gmx dot de
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).