* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
@ 2022-10-03 14:48 ` marxin at gcc dot gnu.org
2022-10-03 19:34 ` pinskia at gcc dot gnu.org
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-10-03 14:48 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Martin Liška <marxin at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Last reconfirmed| |2022-10-03
CC| |marxin at gcc dot gnu.org,
| |rguenth at gcc dot gnu.org
Summary|wrong code with -Os |[11/12 Regression] wrong
|-fno-ipa-vrp |code with -Os -fno-ipa-vrp
|-fno-tree-bit-ccp |-fno-tree-bit-ccp
Ever confirmed|0 |1
--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
It's there since the introduction of __builtin_shufflevector
(r12-1128-gef8176e0fac935c0).
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
2022-10-03 14:48 ` [Bug target/107131] [11/12 Regression] " marxin at gcc dot gnu.org
@ 2022-10-03 19:34 ` pinskia at gcc dot gnu.org
2022-10-03 19:40 ` pinskia at gcc dot gnu.org
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-03 19:34 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Note there is a missed optimization here (unrelated to the wrong code):
_32 = o_13(D) == 0;
_35 = (long int) _32;
_36 = -_35;
_109 = (long long unsigned int) _36;
_102 = _109 > 10439075533421201520;
This should just be:
_32 = o_13(D) == 0;
_ = (long long unsigned int) _32;
_109 = -_35;
Let me file that as a seperate bug.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
2022-10-03 14:48 ` [Bug target/107131] [11/12 Regression] " marxin at gcc dot gnu.org
2022-10-03 19:34 ` pinskia at gcc dot gnu.org
@ 2022-10-03 19:40 ` pinskia at gcc dot gnu.org
2022-10-06 7:12 ` [Bug target/107131] [11/12/13 " rguenth at gcc dot gnu.org
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-10-03 19:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #2)
> Let me file that as a seperate bug.
Created PR 107137.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (2 preceding siblings ...)
2022-10-03 19:40 ` pinskia at gcc dot gnu.org
@ 2022-10-06 7:12 ` rguenth at gcc dot gnu.org
2022-10-18 8:38 ` rguenth at gcc dot gnu.org
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-06 7:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12 Regression] wrong |[11/12/13 Regression] wrong
|code with -Os -fno-ipa-vrp |code with -Os -fno-ipa-vrp
|-fno-tree-bit-ccp |-fno-tree-bit-ccp
Target Milestone|--- |11.4
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
Note __builtin_shufflevector might just be the point we were able to produce
the
input GIMPLE required to trigger the previously latent issue.
The difference between -O (working) and -Os (failing) starts at RTL expansion
only.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (3 preceding siblings ...)
2022-10-06 7:12 ` [Bug target/107131] [11/12/13 " rguenth at gcc dot gnu.org
@ 2022-10-18 8:38 ` rguenth at gcc dot gnu.org
2022-11-18 12:52 ` jakub at gcc dot gnu.org
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-10-18 8:38 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Priority|P3 |P2
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (4 preceding siblings ...)
2022-10-18 8:38 ` rguenth at gcc dot gnu.org
@ 2022-11-18 12:52 ` jakub at gcc dot gnu.org
2023-01-13 10:15 ` cvs-commit at gcc dot gnu.org
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-11-18 12:52 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jakub at gcc dot gnu.org
--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This doesn't fail on the trunk anymore since
r13-3217-gc4d15dddf6b9eacb36f535807ad2ee364af46e04
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (5 preceding siblings ...)
2022-11-18 12:52 ` jakub at gcc dot gnu.org
@ 2023-01-13 10:15 ` cvs-commit at gcc dot gnu.org
2023-01-13 14:01 ` jakub at gcc dot gnu.org
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-13 10:15 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:add71b95dd27d73d64eee0a9c8f748672b7050f5
commit r13-5139-gadd71b95dd27d73d64eee0a9c8f748672b7050f5
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jan 13 11:13:22 2023 +0100
testsuite: Add testcase for PR that went latent in GCC 13 [PR107131]
The following testcase is probably latent since r13-3217-gc4d15dddf6b9e.
Adding testcase so that it doesn't silently reappear.
2023-01-13 Jakub Jelinek <jakub@redhat.com>
PR target/107131
* gcc.dg/pr107131.c: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (6 preceding siblings ...)
2023-01-13 10:15 ` cvs-commit at gcc dot gnu.org
@ 2023-01-13 14:01 ` jakub at gcc dot gnu.org
2023-01-13 16:27 ` jakub at gcc dot gnu.org
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-13 14:01 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
If I change the testcase to:
/* PR target/107131 */
/* { dg-do run } */
/* { dg-options "-Os -fno-ipa-vrp -fno-tree-bit-ccp -Wno-psabi" } */
typedef unsigned char C;
typedef unsigned long long __attribute__((__vector_size__ (32))) U;
typedef unsigned long long __attribute__((__vector_size__ (64))) V;
static __attribute__((__noclone__)) C
foo (C o, U x, U y, U z)
{
V w = { x[0], x[1], x[2], x[3], 0, 0, 0, 0 };
V a = __builtin_shuffle (w, w, (V) {3, 1, 3, 0, 0, 1, 1, 3});
V b = (V) { } >= o;
V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL });
U d = __builtin_shuffle (y, z, (U) {3, 1, 4, 5});
V e = a + c;
U f = ((union { V v; U u[2]; }) e).u[1] + d;
return ((union { U u; C c[32]; }) f).c[9];
}
int
main ()
{
if (__SIZEOF_LONG_LONG__ != 8 || __CHAR_BIT__ != 8)
return 0;
C x = foo (0, (U) { }, (U) { }, (U) { });
if (x != 0xff)
__builtin_abort();
return 0;
}
then it started with r12-1055-gb6bdd7a4cb41ee057f2d064fffcb00f23ce6b497
already,
but similarly to the other testcase got fixed or made latent with
r13-3217.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (7 preceding siblings ...)
2023-01-13 14:01 ` jakub at gcc dot gnu.org
@ 2023-01-13 16:27 ` jakub at gcc dot gnu.org
2023-01-13 16:39 ` cvs-commit at gcc dot gnu.org
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-13 16:27 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hjl.tools at gmail dot com,
| |uros at gcc dot gnu.org
--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think the problem happens during combine. Parts of the vector code related
to:
V b = (V) { } >= o;
V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL });
- in particular the scalar c[5] computation, i.e.
unsigned long long b = 0 >= o ? -1ULL : 0ULL;
unsigned long long c = b <= (b >= 0x90DF0BE3990AC871ULL ? -1ULL : 0ULL) ? -1ULL
: 0ULL;
evaluates to 0 rather than -1 that it should when o is 0.
This boils down to:
__attribute__((noipa)) unsigned long long
foo (unsigned char o)
{
unsigned long long t1 = -(long long) (o == 0);
unsigned long long t2 = -(long long) (t1 > 10439075533421201520ULL);
unsigned long long t3 = -(long long) (t1 <= t2);
return t3;
}
int
main ()
{
if (foo (0) != -1ULL)
__builtin_abort ();
return 0;
}
at -O2 or -Os, which was miscompiled starting with r12-303-g86403f4e6e5f7216
and got fixed with r13-3530-g0e36a9c6915c713d30.
No idea why this is marked as 11 regression though...
So, do we need to backport PR107172 change to 12 branch?
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12/13 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (8 preceding siblings ...)
2023-01-13 16:27 ` jakub at gcc dot gnu.org
@ 2023-01-13 16:39 ` cvs-commit at gcc dot gnu.org
2023-01-13 16:42 ` [Bug target/107131] [11/12 " jakub at gcc dot gnu.org
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2023-01-13 16:39 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <jakub@gcc.gnu.org>:
https://gcc.gnu.org/g:254cf9552ffb1693f0bc74f6d25601dafafbc144
commit r13-5150-g254cf9552ffb1693f0bc74f6d25601dafafbc144
Author: Jakub Jelinek <jakub@redhat.com>
Date: Fri Jan 13 17:37:52 2023 +0100
testsuite: Add another testcase from PR107131
This one is hand reduced to problematic code from optimized dump
that used to be miscompiled during combine starting with
r12-303 and fixed with r13-3530 aka PR107172 fix.
2023-01-13 Jakub Jelinek <jakub@redhat.com>
PR target/107131
* gcc.c-torture/execute/pr107131.c: New test.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (9 preceding siblings ...)
2023-01-13 16:39 ` cvs-commit at gcc dot gnu.org
@ 2023-01-13 16:42 ` jakub at gcc dot gnu.org
2023-04-27 12:02 ` rguenth at gcc dot gnu.org
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-01-13 16:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|[11/12/13 Regression] wrong |[11/12 Regression] wrong
|code with -Os -fno-ipa-vrp |code with -Os -fno-ipa-vrp
|-fno-tree-bit-ccp |-fno-tree-bit-ccp
--- Comment #10 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Anyway, clearly fixed on the trunk + testsuite covered in case it reappears.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (10 preceding siblings ...)
2023-01-13 16:42 ` [Bug target/107131] [11/12 " jakub at gcc dot gnu.org
@ 2023-04-27 12:02 ` rguenth at gcc dot gnu.org
2023-04-27 12:03 ` rguenth at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-27 12:02 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #11 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #8)
> I think the problem happens during combine. Parts of the vector code
> related to:
> V b = (V) { } >= o;
> V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL });
> - in particular the scalar c[5] computation, i.e.
> unsigned long long b = 0 >= o ? -1ULL : 0ULL;
> unsigned long long c = b <= (b >= 0x90DF0BE3990AC871ULL ? -1ULL : 0ULL) ?
> -1ULL : 0ULL;
> evaluates to 0 rather than -1 that it should when o is 0.
>
> This boils down to:
> __attribute__((noipa)) unsigned long long
> foo (unsigned char o)
> {
> unsigned long long t1 = -(long long) (o == 0);
> unsigned long long t2 = -(long long) (t1 > 10439075533421201520ULL);
> unsigned long long t3 = -(long long) (t1 <= t2);
> return t3;
> }
>
> int
> main ()
> {
> if (foo (0) != -1ULL)
> __builtin_abort ();
> return 0;
> }
> at -O2 or -Os, which was miscompiled starting with r12-303-g86403f4e6e5f7216
> and got fixed with r13-3530-g0e36a9c6915c713d30.
> No idea why this is marked as 11 regression though...
>
> So, do we need to backport PR107172 change to 12 branch?
Yes. Testing that now.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (11 preceding siblings ...)
2023-04-27 12:02 ` rguenth at gcc dot gnu.org
@ 2023-04-27 12:03 ` rguenth at gcc dot gnu.org
2023-05-29 10:07 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-04-27 12:03 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #11)
> (In reply to Jakub Jelinek from comment #8)
> > I think the problem happens during combine. Parts of the vector code
> > related to:
> > V b = (V) { } >= o;
> > V c = b <= (V)(b >= (V) { 0, 0, 0, 0, 0, 0x90DF0BE3990AC871ULL });
> > - in particular the scalar c[5] computation, i.e.
> > unsigned long long b = 0 >= o ? -1ULL : 0ULL;
> > unsigned long long c = b <= (b >= 0x90DF0BE3990AC871ULL ? -1ULL : 0ULL) ?
> > -1ULL : 0ULL;
> > evaluates to 0 rather than -1 that it should when o is 0.
> >
> > This boils down to:
> > __attribute__((noipa)) unsigned long long
> > foo (unsigned char o)
> > {
> > unsigned long long t1 = -(long long) (o == 0);
> > unsigned long long t2 = -(long long) (t1 > 10439075533421201520ULL);
> > unsigned long long t3 = -(long long) (t1 <= t2);
> > return t3;
> > }
> >
> > int
> > main ()
> > {
> > if (foo (0) != -1ULL)
> > __builtin_abort ();
> > return 0;
> > }
> > at -O2 or -Os, which was miscompiled starting with r12-303-g86403f4e6e5f7216
> > and got fixed with r13-3530-g0e36a9c6915c713d30.
> > No idea why this is marked as 11 regression though...
> >
> > So, do we need to backport PR107172 change to 12 branch?
>
> Yes. Testing that now.
Not. Not picking cleanly.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Bug target/107131] [11/12 Regression] wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp
2022-10-03 13:37 [Bug target/107131] New: wrong code with -Os -fno-ipa-vrp -fno-tree-bit-ccp zsojka at seznam dot cz
` (12 preceding siblings ...)
2023-04-27 12:03 ` rguenth at gcc dot gnu.org
@ 2023-05-29 10:07 ` jakub at gcc dot gnu.org
13 siblings, 0 replies; 15+ messages in thread
From: jakub at gcc dot gnu.org @ 2023-05-29 10:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107131
Jakub Jelinek <jakub at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Target Milestone|11.4 |11.5
--- Comment #13 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.4 is being released, retargeting bugs to GCC 11.5.
^ permalink raw reply [flat|nested] 15+ messages in thread