public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu
@ 2022-07-22 17:31 zhendong.su at inf dot ethz.ch
  2022-07-22 18:52 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779 hjl.tools at gmail dot com
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2022-07-22 17:31 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 106414
           Summary: wrong code at -O1 and above on x86_64-linux-gnu
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

It appears to be a recent regression.

[672] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/suz-local/software/local/gcc-trunk/libexec/gcc/x86_64-pc-linux-gnu/13.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++ --disable-werror --enable-multilib
--with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 13.0.0 20220722 (experimental) [master r13-1799-g41da4070a2a] (GCC) 
[673] % 
[673] % gcctk -O0 small.c; ./a.out
[674] % gcctk -O1 small.c
[675] % ./a.out
Aborted
[676] % cat small.c
int printf(const char *, ...);
int a, c, e;
const int b = 1;
char d;
int main() {
  a = ~(e || 0) ^ b & ~d;
  d = ~(a | ~2);
  if (d)
    __builtin_abort();
  return 0;
}

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
@ 2022-07-22 18:52 ` hjl.tools at gmail dot com
  2022-07-22 18:53 ` hjl.tools at gmail dot com
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2022-07-22 18:52 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
     Ever confirmed|0                           |1
                 CC|                            |rguenther at suse dot de
            Summary|wrong code at -O1 and above |[13 Regression] wrong code
                   |on x86_64-linux-gnu         |at -O1 and above on
                   |                            |x86_64-linux-gnu by
                   |                            |r13-1779
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2022-07-22

--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
It is caused by r13-1779

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2022-07-22 18:52 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779 hjl.tools at gmail dot com
@ 2022-07-22 18:53 ` hjl.tools at gmail dot com
  2022-07-22 21:23 ` zhendong.su at inf dot ethz.ch
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: hjl.tools at gmail dot com @ 2022-07-22 18:53 UTC (permalink / raw)
  To: gcc-bugs

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

H.J. Lu <hjl.tools at gmail dot com> changed:

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

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
  2022-07-22 18:52 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779 hjl.tools at gmail dot com
  2022-07-22 18:53 ` hjl.tools at gmail dot com
@ 2022-07-22 21:23 ` zhendong.su at inf dot ethz.ch
  2022-07-25  7:03 ` marxin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2022-07-22 21:23 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Zhendong Su <zhendong.su at inf dot ethz.ch> ---
A couple of related tests that fail at -O0: 

[587] % gcctk -O0 small.c
[588] % ./a.out
Aborted
[589] % cat small.c
int a, b, c, d;
unsigned e;
int main() {
  c = e = -((a && 1) ^ ~(b || 0));
  if (e < -1)
    d = c;
  if (!d)
    __builtin_abort();
  return 0;
}

-----

[598] % gcctk -O0 small.c
[599] % ./a.out
Floating point exception
[600] % cat small.c
int a = 1, b = 1, c, d;
int main() {
 L:
  c = d / (1 / a);
  if (b) {
    a = ~((~(a || 0) ^ (1 && b)) % 3U);
    b = 0;
    goto L;
  }
  return 0;
}

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2022-07-22 21:23 ` zhendong.su at inf dot ethz.ch
@ 2022-07-25  7:03 ` marxin at gcc dot gnu.org
  2022-07-25  7:04 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe marxin at gcc dot gnu.org
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-25  7:03 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org

--- Comment #3 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to H.J. Lu from comment #1)
> It is caused by r13-1779

Can you please start using the new format that comes from git gcc-descr:
git gcc-descr 375668e0508fbe173af1ed519d8ae2b79f388d94
r13-1779-g375668e0508fbe
?

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2022-07-25  7:03 ` marxin at gcc dot gnu.org
@ 2022-07-25  7:04 ` marxin at gcc dot gnu.org
  2022-07-25  9:22 ` rguenth at gcc dot gnu.org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: marxin at gcc dot gnu.org @ 2022-07-25  7:04 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |vsevolod.livinskiy at gmail dot co
                   |                            |m

--- Comment #4 from Martin Liška <marxin at gcc dot gnu.org> ---
*** Bug 106417 has been marked as a duplicate of this bug. ***

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2022-07-25  7:04 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe marxin at gcc dot gnu.org
@ 2022-07-25  9:22 ` rguenth at gcc dot gnu.org
  2022-07-25 10:10 ` rguenth at gcc dot gnu.org
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25  9:22 UTC (permalink / raw)
  To: gcc-bugs

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

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

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Mine.

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2022-07-25  9:22 ` rguenth at gcc dot gnu.org
@ 2022-07-25 10:10 ` rguenth at gcc dot gnu.org
  2022-07-25 11:25 ` cvs-commit at gcc dot gnu.org
  2022-07-25 11:25 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25 10:10 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Richard Biener <rguenth at gcc dot gnu.org> ---
Hmm, OK.  With integer valued comparisons considered truth_valued_p
a ~ on them does not result in a truth_value_p.  That in the end means
that we'd need to sign-extend the result or restrict the pattern more.

I'm testing a patch.

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (6 preceding siblings ...)
  2022-07-25 10:10 ` rguenth at gcc dot gnu.org
@ 2022-07-25 11:25 ` cvs-commit at gcc dot gnu.org
  2022-07-25 11:25 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-07-25 11:25 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 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:613e3b86955ea3b4977490625328708e82bea6fa

commit r13-1822-g613e3b86955ea3b4977490625328708e82bea6fa
Author: Richard Biener <rguenther@suse.de>
Date:   Mon Jul 25 12:10:48 2022 +0200

    middle-end/106414 - fix mistake in ~(x ^ y) -> x == y pattern

    When compares are integer typed the inversion with ~ isn't properly
    preserved by the equality comparison even when converting the
    result properly.  The following fixes this by restricting the
    input precisions accordingly.

            PR middle-end/106414
            * match.pd (~(x ^ y) -> x == y): Restrict to single bit
            precision types.

            * gcc.dg/torture/pr106414-1.c: New testcase.
            * gcc.dg/torture/pr106414-2.c: Likewise.

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

* [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe
  2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (7 preceding siblings ...)
  2022-07-25 11:25 ` cvs-commit at gcc dot gnu.org
@ 2022-07-25 11:25 ` rguenth at gcc dot gnu.org
  8 siblings, 0 replies; 10+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-07-25 11:25 UTC (permalink / raw)
  To: gcc-bugs

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #8 from Richard Biener <rguenth at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2022-07-25 11:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-22 17:31 [Bug tree-optimization/106414] New: wrong code at -O1 and above on x86_64-linux-gnu zhendong.su at inf dot ethz.ch
2022-07-22 18:52 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779 hjl.tools at gmail dot com
2022-07-22 18:53 ` hjl.tools at gmail dot com
2022-07-22 21:23 ` zhendong.su at inf dot ethz.ch
2022-07-25  7:03 ` marxin at gcc dot gnu.org
2022-07-25  7:04 ` [Bug tree-optimization/106414] [13 Regression] wrong code at -O1 and above on x86_64-linux-gnu by r13-1779-g375668e0508fbe marxin at gcc dot gnu.org
2022-07-25  9:22 ` rguenth at gcc dot gnu.org
2022-07-25 10:10 ` rguenth at gcc dot gnu.org
2022-07-25 11:25 ` cvs-commit at gcc dot gnu.org
2022-07-25 11:25 ` 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).