[Bug middle-end/105638] New: Redundant stores aren't removed by DSE
hjl.tools at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue May 17 23:29:05 GMT 2022
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?
More information about the Gcc-bugs
mailing list