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

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).