public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
@ 2021-08-18 10:52 channhuang at 163 dot com
  2021-08-18 11:42 ` [Bug rtl-optimization/101958] " marxin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: channhuang at 163 dot com @ 2021-08-18 10:52 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 101958
           Summary: compiling with "-O2 -fselective-scheduling2
                    -fno-tree-ch" produce bad result
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Keywords: missed-optimization, wrong-code
          Severity: normal
          Priority: P3
         Component: rtl-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: channhuang at 163 dot com
                CC: jakub at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-pc-linux-gnu
            Target: x86_64-pc-linux-gnu
             Build: x86_64-pc-linux-gnu

gcc-11.2.0, x86_64-pc-linux-gnu, compiling with the following options:
"-O2 -fselective-scheduling2 -fno-tree-ch -lm"
The source code is for counting the number of primes up to 10000.

#include <stdio.h>
#include <math.h>

unsigned long  max_prime =10000;
int cpu_execute_event()
{
  unsigned long c,l;
  int n = 0;
  double t;

  for(c = 2; c < max_prime; c++)
  {
    t = sqrt((double)c);
    for(l = 2; l <= t; l++)
      if (c % l == 0)
        break;
    if (l > t )
      n++;
  }
  return n;                                                                     
}

int main ()
{
        int n;
        n = cpu_execute_event();
        printf("n:%d\n",n);
        return 0;
}

The real return value of cpu_execute_event() is 2 where it should be 1229.
It works correctly when I compiled with "-O2 -fselective-scheduling2" or "-O2
-fno-tree-ch".I suspect that instruction scheduling changes the meaning of the
code.And gcc10.2 also produces the same phenomenon.

The command line is the following:
gcc-11.2 cpu_execute_event.c -O2 -fselective-scheduling2 -fno-tree-ch -lm

There is no output message, no error, no warning even compiled with the options
"-Wall -Wextra".

I use gcc 11.2.0, configured with:
../gcc-11.2.0/configure --prefix=/home/chann/gcc/gcc11_2 --enable-threads=posix
--disable-checking --disable-multilib --enable-languages=c,c++

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

* [Bug rtl-optimization/101958] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
@ 2021-08-18 11:42 ` marxin at gcc dot gnu.org
  2021-08-18 11:44 ` [Bug rtl-optimization/101958] [9/10/11/12 Regression] " jakub at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: marxin at gcc dot gnu.org @ 2021-08-18 11:42 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |marxin at gcc dot gnu.org
             Status|UNCONFIRMED                 |NEW
     Ever confirmed|0                           |1
   Last reconfirmed|                            |2021-08-18

--- Comment #1 from Martin Liška <marxin at gcc dot gnu.org> ---
Confirmed, started with r9-6789-g8bad0ced9fad845e.

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

* [Bug rtl-optimization/101958] [9/10/11/12 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
  2021-08-18 11:42 ` [Bug rtl-optimization/101958] " marxin at gcc dot gnu.org
@ 2021-08-18 11:44 ` jakub at gcc dot gnu.org
  2022-01-17 13:54 ` rguenth at gcc dot gnu.org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-08-18 11:44 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |9.5
            Summary|compiling with "-O2         |[9/10/11/12 Regression]
                   |-fselective-scheduling2     |compiling with "-O2
                   |-fno-tree-ch" produce bad   |-fselective-scheduling2
                   |result                      |-fno-tree-ch" produce bad
                   |                            |result

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Then it is a regression.

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

* [Bug rtl-optimization/101958] [9/10/11/12 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
  2021-08-18 11:42 ` [Bug rtl-optimization/101958] " marxin at gcc dot gnu.org
  2021-08-18 11:44 ` [Bug rtl-optimization/101958] [9/10/11/12 Regression] " jakub at gcc dot gnu.org
@ 2022-01-17 13:54 ` rguenth at gcc dot gnu.org
  2022-05-27  9:46 ` [Bug rtl-optimization/101958] [10/11/12/13 " 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-01-17 13:54 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2

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

* [Bug rtl-optimization/101958] [10/11/12/13 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
                   ` (2 preceding siblings ...)
  2022-01-17 13:54 ` rguenth at gcc dot gnu.org
@ 2022-05-27  9:46 ` rguenth at gcc dot gnu.org
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-05-27  9:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|9.5                         |10.4

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 9 branch is being closed

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

* [Bug rtl-optimization/101958] [10/11/12/13 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
                   ` (3 preceding siblings ...)
  2022-05-27  9:46 ` [Bug rtl-optimization/101958] [10/11/12/13 " rguenth at gcc dot gnu.org
@ 2022-06-28 10:46 ` jakub at gcc dot gnu.org
  2023-07-07 10:40 ` [Bug rtl-optimization/101958] [11/12/13/14 " rguenth at gcc dot gnu.org
  2024-03-11  3:47 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-06-28 10:46 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.4                        |10.5

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 10.4 is being released, retargeting bugs to GCC 10.5.

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

* [Bug rtl-optimization/101958] [11/12/13/14 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
                   ` (4 preceding siblings ...)
  2022-06-28 10:46 ` jakub at gcc dot gnu.org
@ 2023-07-07 10:40 ` rguenth at gcc dot gnu.org
  2024-03-11  3:47 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: rguenth at gcc dot gnu.org @ 2023-07-07 10:40 UTC (permalink / raw)
  To: gcc-bugs

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|10.5                        |11.5

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
GCC 10 branch is being closed.

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

* [Bug rtl-optimization/101958] [11/12/13/14 Regression] compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result
  2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
                   ` (5 preceding siblings ...)
  2023-07-07 10:40 ` [Bug rtl-optimization/101958] [11/12/13/14 " rguenth at gcc dot gnu.org
@ 2024-03-11  3:47 ` law at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: law at gcc dot gnu.org @ 2024-03-11  3:47 UTC (permalink / raw)
  To: gcc-bugs

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

Jeffrey A. Law <law at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org
           Priority|P2                          |P4

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

end of thread, other threads:[~2024-03-11  3:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-18 10:52 [Bug rtl-optimization/101958] New: compiling with "-O2 -fselective-scheduling2 -fno-tree-ch" produce bad result channhuang at 163 dot com
2021-08-18 11:42 ` [Bug rtl-optimization/101958] " marxin at gcc dot gnu.org
2021-08-18 11:44 ` [Bug rtl-optimization/101958] [9/10/11/12 Regression] " jakub at gcc dot gnu.org
2022-01-17 13:54 ` rguenth at gcc dot gnu.org
2022-05-27  9:46 ` [Bug rtl-optimization/101958] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2023-07-07 10:40 ` [Bug rtl-optimization/101958] [11/12/13/14 " rguenth at gcc dot gnu.org
2024-03-11  3:47 ` law 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).