public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre
@ 2022-06-22  6:20 zsojka at seznam dot cz
  2022-06-22 20:44 ` [Bug tree-optimization/106053] " pinskia at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zsojka at seznam dot cz @ 2022-06-22  6:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

            Bug ID: 106053
           Summary: [13 Regression] wrong code with -O -fno-tree-fre
           Product: gcc
           Version: 13.0
            Status: UNCONFIRMED
          Keywords: wrong-code
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zsojka at seznam dot cz
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu

Created attachment 53188
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53188&action=edit
reduced testcase

Output:
$ x86_64-pc-linux-gnu-gcc -O -fno-tree-fre testcase.c -Wno-psabi
$ ./a.out 
Aborted

$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-r13-1189-20220621080317-g7905a9ac267-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --with-cloog --with-ppl --with-isl
--build=x86_64-pc-linux-gnu --host=x86_64-pc-linux-gnu
--target=x86_64-pc-linux-gnu --with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-r13-1189-20220621080317-g7905a9ac267-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.0.0 20220621 (experimental) (GCC)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug tree-optimization/106053] [13 Regression] wrong code with -O -fno-tree-fre
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
@ 2022-06-22 20:44 ` pinskia at gcc dot gnu.org
  2022-06-27  8:52 ` [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2022-06-22 20:44 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |13.0

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
  2022-06-22 20:44 ` [Bug tree-optimization/106053] " pinskia at gcc dot gnu.org
@ 2022-06-27  8:52 ` marxin at gcc dot gnu.org
  2022-06-27  9:09 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-06-27  8:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

Martin Liška <marxin at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2022-06-27
             Status|UNCONFIRMED                 |NEW
           Keywords|needs-bisection             |
                 CC|                            |marxin at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org
            Summary|[13 Regression] wrong code  |[13 Regression] wrong code
                   |with -O -fno-tree-fre       |with -O -fno-tree-fre since
                   |                            |r13-707-g68e0063397ba820e
     Ever confirmed|0                           |1

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Started with r13-707-g68e0063397ba820e.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
  2022-06-22 20:44 ` [Bug tree-optimization/106053] " pinskia at gcc dot gnu.org
  2022-06-27  8:52 ` [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e marxin at gcc dot gnu.org
@ 2022-06-27  9:09 ` rguenth at gcc dot gnu.org
  2022-06-27 12:55 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-27  9:09 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
                   ` (2 preceding siblings ...)
  2022-06-27  9:09 ` rguenth at gcc dot gnu.org
@ 2022-06-27 12:55 ` rguenth at gcc dot gnu.org
  2022-06-28  8:43 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-27 12:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
It works with -mavx or when 'foo' is early inlined (using always-inline).

Working:

  u.1_8 = u;
  _9 = (long long unsigned int) u.1_8;
  u64_0_10 = _9 | 23725760132;
  _18 = u64_0_10 * 3095179400;
  _50 = _18 == 0;
  _53 = (__int128) _50;
  _54 = -_53;
  _58 = (__int128) _50;
  _59 = -_58;
  D.2295.a = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  _69 = BIT_FIELD_REF <D.2295.b[0], 128, 128>;
  _66 = BIT_FIELD_REF <D.2295.b[0], 128, 0>;
  _67 = VIEW_CONVERT_EXPR<vector(4) unsigned int>(_54);
  _68 = _66 + _67;
  _70 = VIEW_CONVERT_EXPR<vector(4) unsigned int>(_59);
  _71 = _69 + _70;
  v256u8_r_26 = {_68, _71};
  x = v256u8_r_26;

not working:

  u.1_27 = u;
  _28 = (long long unsigned int) u.1_27;
  u64_0_29 = _28 | 23725760132;
  _38 = u64_0_29 * 3095179400;
  _56 = _38 == 0;
  _59 = (__int128) _56;
  _60 = -_59;
  D.2034.a = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
  _70 = BIT_FIELD_REF <D.2034.b[0], 128, 128>;
  _67 = BIT_FIELD_REF <D.2034.b[0], 128, 0>;
  _69 = _67 + { 4294967295, 4294967295, 4294967295, 4294967295 };
  _71 = VIEW_CONVERT_EXPR<vector(4) unsigned int>(_60);
  _72 = _70 + _71;
  BIT_FIELD_REF <x, 128, 0> = _69;
  BIT_FIELD_REF <x, 128, 128> = _72;

and CCP produces the bogus constant folded vector from

  _38 = u64_0_29 * 3095179400;
  _1 = (<signed-boolean:128>) _38;
  _50 = _1 ^ 1;
  _53 = _50 & 1;
  _54 = (__int128) _53;
  _55 = -_54;
  _68 = VIEW_CONVERT_EXPR<vector(4) unsigned int>(_55);
  _69 = _68 + _67;

but it's interpretations are OK I think.  It must go wrong in veclower somehow,
the broken version ends up with a compare in signed-bool while the working
one uses an __int128 compare.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
                   ` (3 preceding siblings ...)
  2022-06-27 12:55 ` rguenth at gcc dot gnu.org
@ 2022-06-28  8:43 ` rguenth at gcc dot gnu.org
  2022-06-28 10:00 ` cvs-commit at gcc dot gnu.org
  2022-06-28 10:11 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-28  8:43 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
It's fold_sign_changed_comparison (in it's match.pd incarnation) that replaces
(uint128) a == (uint128) b with a == (signed-bool:128) b.  That's a latent
issue exposed by the change as we now fold this comparison while we didn't
before.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
                   ` (4 preceding siblings ...)
  2022-06-28  8:43 ` rguenth at gcc dot gnu.org
@ 2022-06-28 10:00 ` cvs-commit at gcc dot gnu.org
  2022-06-28 10:11 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-28 10:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

--- 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:a3ca1fc5f409e257e9fb9a8165bb4a7068ddebbe

commit r13-1317-ga3ca1fc5f409e257e9fb9a8165bb4a7068ddebbe
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Jun 28 10:50:34 2022 +0200

    middle-end/106053 - fold_sign_changed_comparison and large bools

    The following fixes a latent issue in the match.pd variant of
    fold_sign_changed_comparison which replaces an unsigned integer
    comparison with a signed boolean comparison of the same precision
    despite the fact that we treat BOOLEAN_TYPEs as only having two
    valid values.

    2022-06-28  Richard Biener  <rguenther@suse.de>

            PR middle-end/106053
            * match.pd ((T)a == (T)b): Avoid folding away sign
            changes in a comparison if we'd truncate to a boolean.

            * gcc.target/i386/pr106053.c: New testcase.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e
  2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
                   ` (5 preceding siblings ...)
  2022-06-28 10:00 ` cvs-commit at gcc dot gnu.org
@ 2022-06-28 10:11 ` rguenth at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-06-28 10:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106053

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 on trunk.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-06-28 10:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-22  6:20 [Bug tree-optimization/106053] New: [13 Regression] wrong code with -O -fno-tree-fre zsojka at seznam dot cz
2022-06-22 20:44 ` [Bug tree-optimization/106053] " pinskia at gcc dot gnu.org
2022-06-27  8:52 ` [Bug target/106053] [13 Regression] wrong code with -O -fno-tree-fre since r13-707-g68e0063397ba820e marxin at gcc dot gnu.org
2022-06-27  9:09 ` rguenth at gcc dot gnu.org
2022-06-27 12:55 ` rguenth at gcc dot gnu.org
2022-06-28  8:43 ` rguenth at gcc dot gnu.org
2022-06-28 10:00 ` cvs-commit at gcc dot gnu.org
2022-06-28 10:11 ` 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).