public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug middle-end/105638] New: Redundant stores aren't removed by DSE @ 2022-05-17 23:29 hjl.tools at gmail dot com 2022-05-18 12:42 ` [Bug middle-end/105638] " rguenth at gcc dot gnu.org ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: hjl.tools at gmail dot com @ 2022-05-17 23:29 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105638 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 <stdint.h> #include <vector> #include <tr1/array> class FastBoard { public: typedef std::pair<int, int> movescore_t; typedef std::tr1::array<movescore_t, 24> scoredlist_t; protected: std::vector<int> m_critical; int m_boardsize; }; class FastState { public: FastBoard board; int movenum; protected: FastBoard::scoredlist_t scoredmoves; }; class KoState : public FastState { private: std::vector<uint64_t> ko_hash_history; std::vector<uint64_t> hash_history; }; class GameState : public KoState { public: void foo (); private: std::vector<KoState> game_history; }; void GameState::foo() { game_history.resize(movenum); } $ g++ -O2 -march=skylake 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: <bb 14> [local count: 444773291]: # __cur_154 = PHI <__cur_42(14), _6(13)> # __n_155 = PHI <__n_41(14), __n_20(D)(13)> *__cur_154 = {}; MEM[(int * *)__cur_154] = 0B; MEM[(int * *)__cur_154 + 8B] = 0B; MEM[(int * *)__cur_154 + 16B] = 0B; MEM[(struct array *)__cur_154 + 36B]._M_instance = {}; MEM <vector(4) long unsigned int> [(long unsigned int * *)__cur_154 + 232B] = { 0, 0, 0, 0 }; MEM[(long unsigned int * *)__cur_154 + 264B] = 0B; MEM[(long unsigned int * *)__cur_154 + 272B] = 0B; Some of them are removed by RTL DSE. But vector stores aren't. Should SSA DSE remove them? ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/105638] Redundant stores aren't removed by DSE 2022-05-17 23:29 [Bug middle-end/105638] New: Redundant stores aren't removed by DSE hjl.tools at gmail dot com @ 2022-05-18 12:42 ` rguenth at gcc dot gnu.org 2022-06-01 21:23 ` cvs-commit at gcc dot gnu.org 2022-06-14 13:53 ` hjl.tools at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: rguenth at gcc dot gnu.org @ 2022-05-18 12:42 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105638 Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2022-05-18 Ever confirmed|0 |1 Keywords| |missed-optimization --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- DSE doesn't remove redundant stores, in some cases it can prune an earlier store but that's only handled in a limited set of cases. The issue with removing redundant stores is that side-effects on the effective dynamic type have to be preserved so removing earlier stores is much better. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/105638] Redundant stores aren't removed by DSE 2022-05-17 23:29 [Bug middle-end/105638] New: Redundant stores aren't removed by DSE hjl.tools at gmail dot com 2022-05-18 12:42 ` [Bug middle-end/105638] " rguenth at gcc dot gnu.org @ 2022-06-01 21:23 ` cvs-commit at gcc dot gnu.org 2022-06-14 13:53 ` hjl.tools at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: cvs-commit at gcc dot gnu.org @ 2022-06-01 21:23 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105638 --- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by H.J. Lu <hjl@gcc.gnu.org>: https://gcc.gnu.org/g:a743a72714fc4a9d7036d28d0cacdf2a3621f629 commit r13-921-ga743a72714fc4a9d7036d28d0cacdf2a3621f629 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed May 18 13:00:47 2022 -0700 DSE: Use the constant store source if possible RTL DSE tracks redundant constant stores within a basic block. When RTL loop invariant motion hoists a constant initialization out of the loop into a separate basic block, the constant store value becomes unknown within the original basic block. When recording store for RTL DSE, check if the source register is set only once to a constant by a non-partial unconditional load. If yes, record the constant as the constant store source. It eliminates unrolled zero stores after memset 0 in a loop where a vector register is used as the zero store source. gcc/ PR rtl-optimization/105638 * df-core.cc (df_find_single_def_src): Moved and renamed from find_single_def_src in loop-iv.cc. Change the argument to rtx and use rtx_equal_p. Return null for partial or conditional defs. * df.h (df_find_single_def_src): New prototype. * dse.cc (record_store): Use the constant source if the source register is set only once. * loop-iv.cc (find_single_def_src): Moved to df-core.cc. (replace_single_def_regs): Replace find_single_def_src with df_find_single_def_src. gcc/testsuite/ PR rtl-optimization/105638 * g++.target/i386/pr105638.C: New test. ^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug middle-end/105638] Redundant stores aren't removed by DSE 2022-05-17 23:29 [Bug middle-end/105638] New: Redundant stores aren't removed by DSE hjl.tools at gmail dot com 2022-05-18 12:42 ` [Bug middle-end/105638] " rguenth at gcc dot gnu.org 2022-06-01 21:23 ` cvs-commit at gcc dot gnu.org @ 2022-06-14 13:53 ` hjl.tools at gmail dot com 2 siblings, 0 replies; 4+ messages in thread From: hjl.tools at gmail dot com @ 2022-06-14 13:53 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105638 H.J. Lu <hjl.tools at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|NEW |RESOLVED Target Milestone|--- |13.0 --- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> --- Fixed. ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-06-14 13:53 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-05-17 23:29 [Bug middle-end/105638] New: Redundant stores aren't removed by DSE hjl.tools at gmail dot com 2022-05-18 12:42 ` [Bug middle-end/105638] " rguenth at gcc dot gnu.org 2022-06-01 21:23 ` cvs-commit at gcc dot gnu.org 2022-06-14 13:53 ` hjl.tools at gmail dot com
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).