https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117924

            Bug ID: 117924
           Summary: unused std::vector<bool> are not optimized out fully
                    at gimple level
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: hubicka at gcc dot gnu.org
  Target Milestone: ---

compiling:
#include <vector>
void
empty(std::vector<bool> src)
{
        std::vector <bool> data=src;
}

yields in optimized dump:

void empty (struct vector & src)
{
  _Bit_type * _13;
  unsigned int _14;
  _Bit_type * _15;
  long int _16;
  long int _17;
  long int _18;
  long int _19;
  long unsigned int _20;
  long unsigned int _25;
  long unsigned int _26;
  long unsigned int _45;

  <bb 2> [local count: 1073741824]:
  _13 = MEM[(const struct vector
*)src_2(D)].D.25603._M_impl.D.25087._M_start.D.16487._M_p;
  _14 = MEM[(const struct _Bit_iterator &)src_2(D) + 16].D.16487._M_offset;
  _15 = MEM[(const struct _Bit_iterator &)src_2(D) + 16].D.16487._M_p;
  _16 = _15 - _13;
  _17 = _16 * 8;
  _18 = (long int) _14;
  _19 = _17 + _18;
  if (_19 != 0)
    goto <bb 3>; [33.00%]
  else
    goto <bb 4>; [67.00%]

  <bb 3> [local count: 574129755]:
  _20 = (long unsigned int) _19;
  _25 = _20 + 63;
  _26 = _25 >> 6;
  _45 = _26 * 8;

  <bb 4> [local count: 1073741824]:
  return;

}
All the computations are obviously dead.
Eventually RTL optimizes it out, but we ought to do it earlier. Unused
new/delete pair is only being determined at cddce3 which is bit late. At cddce2
we still have memcpy copying the vector which is only detected dead by dse5 run
shortly before. Dse4 is not run and during dse3 we get quite a lot of code
which somehow prevents the dse from happening.



If bool is changed to int memcpy goes away already during dse2.

Reply via email to