public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/107323] New: Problem with GCC optimizition
@ 2022-10-19 19:42 fatemetmhr at gmail dot com
  2022-10-19 19:59 ` [Bug tree-optimization/107323] [10/11/12 Regression] Loop distribute issue pinskia at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: fatemetmhr at gmail dot com @ 2022-10-19 19:42 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 107323
           Summary: Problem with GCC optimizition
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: fatemetmhr at gmail dot com
  Target Milestone: ---

Created attachment 53732
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53732&action=edit
The code

Hi! 

I faced a problem with GCC optimizitions on codeforces.com. I used GNU G++20
11.2.0 (64 bit, winlibs) for my code but the bug can be found in GCC 11.2.0
anywhere else (and even with some other versions of GCC).

Here's the compilation command used in Codeforces:
g++ -Wall -Wextra -Wconversion -static -DONLINE_JUDGE -Wl,--stack=268435456 -O2
-std=c++20 <source>

There's no error or warning while compiling the code. 
The code has different results while using GCC 11.2.0 and GCC 9.2.0. 

There's a problem with -ftree-loop-distribute-patterns. The flag made GCC
generate  a wrong code, including a memset after the `for` part ends, so the
variables will be set to 0 at the end of the process. 
This flag is obviously doing wrong while optimizing the code. And, somehow, it
can be fixed while using -ftree-vectorize. Which isn't turned on automatically
in -O2 with GCC 11.2.0 .
Anyway some other versions of GCC (like 12) seems to still have the problem
with -ftree-loop-distribute-patterns, but just because of using
-ftree-vectorize, they works correctly.

I posted many other codes here, using different optimizitions flags:
https://codeforces.com/blog/entry/108168

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

end of thread, other threads:[~2023-01-26 13:06 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-19 19:42 [Bug tree-optimization/107323] New: Problem with GCC optimizition fatemetmhr at gmail dot com
2022-10-19 19:59 ` [Bug tree-optimization/107323] [10/11/12 Regression] Loop distribute issue pinskia at gcc dot gnu.org
2022-10-20  9:09 ` marxin at gcc dot gnu.org
2022-10-20  9:12 ` marxin at gcc dot gnu.org
2022-10-20  9:21 ` rguenth at gcc dot gnu.org
2022-10-20 11:28 ` rguenth at gcc dot gnu.org
2022-10-20 11:36 ` rguenth at gcc dot gnu.org
2022-10-21  7:07 ` rguenth at gcc dot gnu.org
2022-10-21  7:35 ` rguenth at gcc dot gnu.org
2022-10-21  9:17 ` cvs-commit at gcc dot gnu.org
2022-10-21  9:19 ` cvs-commit at gcc dot gnu.org
2022-10-21  9:20 ` [Bug tree-optimization/107323] [10/11 " rguenth at gcc dot gnu.org
2023-01-10  8:00 ` rguenth at gcc dot gnu.org
2023-01-24 15:22 ` cvs-commit at gcc dot gnu.org
2023-01-26 13:05 ` [Bug tree-optimization/107323] [10 " cvs-commit at gcc dot gnu.org
2023-01-26 13:06 ` 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).