public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu
@ 2020-11-18  9:49 zhendong.su at inf dot ethz.ch
  2020-11-18  9:54 ` [Bug tree-optimization/97888] [11 Regression] " jakub at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: zhendong.su at inf dot ethz.ch @ 2020-11-18  9:49 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 97888
           Summary: wrong code at -Os and above on x86_64-pc-linux-gnu
           Product: gcc
           Version: 11.0
            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: ---

[525] % 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/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--prefix=/local/suz-local/software/local/gcc-trunk --enable-languages=c,c++
--disable-werror --enable-multilib --with-system-zlib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20201118 (experimental) [master revision
b03be74bad0:b7ec4b4b7a1:4b81528241ca682025d92558ff6aeec91dafdca8] (GCC) 
[526] % 
[526] % gcctk -O1 small.c; ./a.out
[527] % 
[527] % gcctk -Os small.c
[528] % ./a.out
Illegal instruction
[529] % 
[529] % cat small.c
int a = 1, b, c = 4, d, e;

int main() {
  int f = 2273363750;
  for (; b < 10; b++) {
    int g = f % (~0 && a) && g, h = 0, i = 0;
    if (c)
      h = f;
    if (h > -2021603546)
      e = d / i;
    f = h;
  }
  return 0;
}

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
@ 2020-11-18  9:54 ` jakub at gcc dot gnu.org
  2020-11-18 10:00 ` jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18  9:54 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |11.0
            Summary|wrong code at -Os and above |[11 Regression] wrong code
                   |on x86_64-pc-linux-gnu      |at -Os and above on
                   |                            |x86_64-pc-linux-gnu
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
           Priority|P3                          |P1
                 CC|                            |aldyh at gcc dot gnu.org,
                   |                            |amacleod at redhat dot com,
                   |                            |jakub at gcc dot gnu.org
   Last reconfirmed|                            |2020-11-18

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Started with r11-5111-g1e27e7a582a9b86bcf86f5c103cd947672746e97

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
  2020-11-18  9:54 ` [Bug tree-optimization/97888] [11 Regression] " jakub at gcc dot gnu.org
@ 2020-11-18 10:00 ` jakub at gcc dot gnu.org
  2020-11-18 10:20 ` jakub at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 10:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
The comments in that commit look incorrect btw,
// if a & b >=0 , then a >= 0.
should have been
// if a % b >=0 , then a >= 0.
(ditto the other one).

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
  2020-11-18  9:54 ` [Bug tree-optimization/97888] [11 Regression] " jakub at gcc dot gnu.org
  2020-11-18 10:00 ` jakub at gcc dot gnu.org
@ 2020-11-18 10:20 ` jakub at gcc dot gnu.org
  2020-11-18 10:33 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 10:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And I think the commit doesn't implement what Bruno wrote.
In particular, it was
b >= 0 && a % b > 0 implies a >= 0
b >= 0 && a % b < 0 implies a <= 0
while the patch implemented
b >= 0 && a % b >= 0 implies a >= 0
b >= 0 && a % b < 0 implies a <= 0

Consider -4 % 4, b >= 0 and a % b == 0, which is >= 0, but a is < 0.

So, another miscompiled testcase is:
__attribute__((noipa)) void
foo (int i)
{
  if ((i % 7) >= 0)
    {
      if (i >= 0)
        __builtin_abort ();
    }
}

int
main ()
{
  foo (-7);
  foo (-21);
  return 0;
}

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (2 preceding siblings ...)
  2020-11-18 10:20 ` jakub at gcc dot gnu.org
@ 2020-11-18 10:33 ` jakub at gcc dot gnu.org
  2020-11-18 13:35 ` amacleod at redhat dot com
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 10:33 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |jakub at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Created attachment 49585
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49585&action=edit
gcc11-pr97888.patch

Untested fix.

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (3 preceding siblings ...)
  2020-11-18 10:33 ` jakub at gcc dot gnu.org
@ 2020-11-18 13:35 ` amacleod at redhat dot com
  2020-11-18 21:17 ` cvs-commit at gcc dot gnu.org
  2020-11-18 21:57 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: amacleod at redhat dot com @ 2020-11-18 13:35 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Andrew Macleod <amacleod at redhat dot com> ---
Doh, yeah. Patch looks good.

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (4 preceding siblings ...)
  2020-11-18 13:35 ` amacleod at redhat dot com
@ 2020-11-18 21:17 ` cvs-commit at gcc dot gnu.org
  2020-11-18 21:57 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-11-18 21:17 UTC (permalink / raw)
  To: gcc-bugs

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

--- 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:71c9d2b088c9d409a1bd3b50523ac4623a5bf1b4

commit r11-5150-g71c9d2b088c9d409a1bd3b50523ac4623a5bf1b4
Author: Jakub Jelinek <jakub@redhat.com>
Date:   Wed Nov 18 22:13:06 2020 +0100

    vrp: Fix operator_trunc_mod::op1_range [PR97888]

    As mentioned in the PR, in (x % y) >= 0 && y >= 0, we can't deduce
    x's range to be x >= 0, as e.g. -7 % 7 is 0.  But we can deduce it
    from (x % y) > 0.  The patch also fixes up the comments.

    2020-11-18  Jakub Jelinek  <jakub@redhat.com>

            PR tree-optimization/91029
            PR tree-optimization/97888
            * range-op.cc (operator_trunc_mod::op1_range): Only set op1
            range to >= 0 if lhs is > 0, rather than >= 0.  Fix up comments.

            * gcc.dg/pr91029.c: Add comment with PR number.
            (f2): Use > 0 rather than >= 0.
            * gcc.c-torture/execute/pr97888-1.c: New test.
            * gcc.c-torture/execute/pr97888-2.c: New test.

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

* [Bug tree-optimization/97888] [11 Regression] wrong code at -Os and above on x86_64-pc-linux-gnu
  2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
                   ` (5 preceding siblings ...)
  2020-11-18 21:17 ` cvs-commit at gcc dot gnu.org
@ 2020-11-18 21:57 ` jakub at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2020-11-18 21:57 UTC (permalink / raw)
  To: gcc-bugs

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

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

--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Fixed.

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

end of thread, other threads:[~2020-11-18 21:57 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-18  9:49 [Bug tree-optimization/97888] New: wrong code at -Os and above on x86_64-pc-linux-gnu zhendong.su at inf dot ethz.ch
2020-11-18  9:54 ` [Bug tree-optimization/97888] [11 Regression] " jakub at gcc dot gnu.org
2020-11-18 10:00 ` jakub at gcc dot gnu.org
2020-11-18 10:20 ` jakub at gcc dot gnu.org
2020-11-18 10:33 ` jakub at gcc dot gnu.org
2020-11-18 13:35 ` amacleod at redhat dot com
2020-11-18 21:17 ` cvs-commit at gcc dot gnu.org
2020-11-18 21:57 ` jakub 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).