From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2552B3858434; Tue, 17 May 2022 23:29:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2552B3858434 From: "hjl.tools at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105638] New: Redundant stores aren't removed by DSE Date: Tue, 17 May 2022 23:29:05 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hjl.tools 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 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 May 2022 23:29:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105638 Bug ID: 105638 Summary: Redundant stores aren't removed by DSE Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Target Milestone: --- For $ cat foo.cpp #include #include #include class FastBoard { public: typedef std::pair movescore_t; typedef std::tr1::array scoredlist_t; protected: std::vector m_critical; int m_boardsize;=20=20=20=20 }; class FastState { public:=20=20=20=20=20=20=20=20 FastBoard board; int movenum;=20=20=20=20=20=20=20=20=20=20=20=20=20=20 protected: FastBoard::scoredlist_t scoredmoves; }; class KoState : public FastState { private:=20=20=20=20=20=20=20=20=20 std::vector ko_hash_history;=20=20=20 std::vector hash_history;=20=20=20=20=20 }; class GameState : public KoState { public:=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 void foo ();=20=20=20=20=20=20 private: std::vector game_history;=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20 }; void GameState::foo() { game_history.resize(movenum); } $ g++ -O2 -march=3Dskylake foo.cpp -S generates: ... movl $280, %edx xorl %esi, %esi call memset movq %rax, %rcx vpxor %xmm0, %xmm0, %xmm0 addq $280, %rcx vmovdqu %xmm0, 36(%rax) vmovdqu %xmm0, 52(%rax) vmovdqu %xmm0, 68(%rax) vmovdqu %xmm0, 84(%rax) vmovdqu %xmm0, 100(%rax) vmovdqu %xmm0, 116(%rax) vmovdqu %xmm0, 132(%rax) vmovdqu %xmm0, 148(%rax) vmovdqu %xmm0, 164(%rax) vmovdqu %xmm0, 180(%rax) vmovdqu %xmm0, 196(%rax) vmovdqu %xmm0, 212(%rax) ... Here memset has cleared 280 bytes starting from RAX. There is no need to clear these bytes again. The optimized tree dump shows: [local count: 444773291]: # __cur_154 =3D PHI <__cur_42(14), _6(13)> # __n_155 =3D PHI <__n_41(14), __n_20(D)(13)> *__cur_154 =3D {}; MEM[(int * *)__cur_154] =3D 0B;=20 MEM[(int * *)__cur_154 + 8B] =3D 0B;=20 MEM[(int * *)__cur_154 + 16B] =3D 0B;=20 MEM[(struct array *)__cur_154 + 36B]._M_instance =3D {};=20 MEM [(long unsigned int * *)__cur_154 + 232= B] =3D { 0, 0, 0, 0 };=20 MEM[(long unsigned int * *)__cur_154 + 264B] =3D 0B;=20 MEM[(long unsigned int * *)__cur_154 + 272B] =3D 0B; Some of them are removed by RTL DSE. But vector stores aren't. Should SSA DSE remove them?=