From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id AB5BB3858D3C; Wed, 19 Oct 2022 19:42:38 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AB5BB3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666208558; bh=Rj0jrO8/iET4GfzXGbQCoYqKCd4ugccdsv+skupOsh4=; h=From:To:Subject:Date:From; b=v4CwKoEj7LXwrnMJJcWv/wvT3H8w7AM/FFy9+yUxyPbdkuoI3k1kRQaQ/CLuqYIow /9z/6NYk09JZEYBRnDzkeCAmGClVcC0UP0rCayPj0DUYWWU7HjWON9Hs8hxQPTIYjo GSogcOY4klxBmBFpVEnCLQwBLVb6uY/Ktj6WZwZA= From: "fatemetmhr at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107323] New: Problem with GCC optimizition Date: Wed, 19 Oct 2022 19:42:38 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: fatemetmhr at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107323 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=3D53732&action=3Dedit The code Hi!=20 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=3D2684354= 56 -O2 -std=3Dc++20 There's no error or warning while compiling the code.=20 The code has different results while using GCC 11.2.0 and GCC 9.2.0.=20 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.=20 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 automatica= lly 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=