[Bug c++/89538] [7.3.0] GCC miscompiling LLVM because of wrong vectorization

marxin at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Mar 5 12:00:00 GMT 2019


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

--- Comment #6 from Martin Liška <marxin at gcc dot gnu.org> ---
(In reply to Taewook Oh from comment #5)
> The name of the function is "void llvm::SmallVectorTemplateBase<T,
> <anonymous> >::grow(size_t) [with T =
> std::pair<std::unique_ptr<llvm::DwarfTypeUnit>, const
> llvm::DICompositeType*>; bool <anonymous> = false]".
> 
> I tried with GCC 7.4.0, and seems that GCC 7.4.0 doesn't attempt to
> vectorize the problematic code. 
> 
> Thank you for taking a look!

Hm, I've just build 7.3.0 release (git revision
87fb575328cc5d954b91672681aacfc383134b12) and I used your command line.
However, I can't see the function being vectorized:

DwarfDebug.cpp.158t.vect:
...
;; Function void llvm::SmallVectorTemplateBase<T, <anonymous> >::grow(size_t)
[with T = std::pair<std::unique_ptr<llvm::DwarfTypeUnit>, const
llvm::DICompositeType*>; bool <anonymous> = false]
(_ZN4llvm23SmallVectorTemplateBaseISt4pairISt10unique_ptrINS_13DwarfTypeUnitESt14default_deleteIS3_EEPKNS_15DICompositeTypeEELb0EE4growEm,
funcdef_no=25366, decl_uid=680829, cgraph_uid=19027, symbol_order=19082)


Analyzing loop at
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:184
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:184:14: note:
===== analyze_loop_nest =====
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:184:14: note:
=== vect_analyze_loop_form ===
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:184:14: note:
not vectorized: control flow in loop.
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:184:14: note:
bad loop form.

Analyzing loop at
/mnt/gvfs/third-party2/gcc/6e8e715624fd15256a7970073387793dfcf79b46/7.x/centos7-native/b2ef2b6/include/c++/7.3.0/bits/stl_uninitialized.h:82
/mnt/gvfs/third-party2/gcc/6e8e715624fd15256a7970073387793dfcf79b46/7.x/centos7-native/b2ef2b6/include/c++/7.3.0/bits/stl_uninitialized.h:82:23:
note: ===== analyze_loop_nest =====
/mnt/gvfs/third-party2/gcc/6e8e715624fd15256a7970073387793dfcf79b46/7.x/centos7-native/b2ef2b6/include/c++/7.3.0/bits/stl_uninitialized.h:82:23:
note: === vect_analyze_loop_form ===
/mnt/gvfs/third-party2/gcc/6e8e715624fd15256a7970073387793dfcf79b46/7.x/centos7-native/b2ef2b6/include/c++/7.3.0/bits/stl_uninitialized.h:82:23:
note: not vectorized: control flow in loop.
/mnt/gvfs/third-party2/gcc/6e8e715624fd15256a7970073387793dfcf79b46/7.x/centos7-native/b2ef2b6/include/c++/7.3.0/bits/stl_uninitialized.h:82:23:
note: bad loop form.
/data/users/twoh/server-llvm/llvm/include/llvm/ADT/SmallVector.h:233:6: note:
vectorized 0 loops in function.
void llvm::SmallVectorTemplateBase<T, <anonymous> >::grow(size_t) [with T =
std::pair<std::unique_ptr<llvm::DwarfTypeUnit>, const llvm::DICompositeType*>;
bool <anonymous> = false] (struct SmallVectorTemplateBase * const this, size_t
MinSize)
{
  void * Result;
  void * D.1212828;
  uint64_t A;
  struct pair * __cur;
  struct pair * __first$_M_current;
  struct pair * E;
  struct pair * NewElts;
  size_t NewCapacity;
  const long unsigned int D.1032599;
  long unsigned int _2;
  long unsigned int _4;
  unsigned int _5;
  void * _13;
  struct DwarfTypeUnit * _18;
  void * _21;
  unsigned int _27;
  struct pair * _28;
  struct DwarfTypeUnit * _31;
  const struct DICompositeType * _32;
  struct pair * _33;
  void * _35;
  unsigned int _36;
  long unsigned int _37;
  long unsigned int _38;
  struct pair * _39;
  long unsigned int _41;
  long unsigned int _42;
  long unsigned int _43;
  long unsigned int _45;
  long unsigned int _47;
  long unsigned int _49;
  long unsigned int _51;
  long unsigned int _53;
  long unsigned int _55;
  long unsigned int _56;
  struct DwarfUnit * _70;
  void * pretmp_124;
  void * prephitmp_125;

  <bb 2> [15.00%]:
  if (MinSize_59(D) > 4294967295)
    goto <bb 3>; [33.00%]
  else
    goto <bb 4>; [67.00%]

  <bb 3> [4.95%]:
  llvm::report_bad_alloc_error ("SmallVector capacity overflow during
allocation", 1);

  <bb 4> [15.00%]:
  # DEBUG D#3730 => &this_10(D)->D.680846.D.680786
  _27 = MEM[(unsigned int *)this_10(D) + 12B];
  # DEBUG D#78 => D#3730
  # DEBUG this => D#78
  _56 = (long unsigned int) _27;
  _2 = _56 + 2;
  # DEBUG A => _2
  _43 = _2 >> 1;
  A_44 = _2 | _43;
  # DEBUG A => A_44
  _45 = A_44 >> 2;
  A_46 = A_44 | _45;
  # DEBUG A => A_46
  _47 = A_46 >> 4;
  A_48 = A_46 | _47;
  # DEBUG A => A_48
  _49 = A_48 >> 8;
  A_50 = A_48 | _49;
  # DEBUG A => A_50
  _51 = A_50 >> 16;
  A_52 = A_50 | _51;
  # DEBUG A => A_52
  _53 = A_52 >> 32;
  A_54 = A_52 | _53;
  # DEBUG A => A_54
  _55 = A_54 + 1;
  # DEBUG A => NULL
  # DEBUG NewCapacity => _55
  # DEBUG __a => &NewCapacity
  # DEBUG __b => &MinSize
  _42 = MAX_EXPR <_55, MinSize_59(D)>;
  # DEBUG __a => NULL
  # DEBUG __b => NULL
  # DEBUG __a => NULL
  # DEBUG __b => &D.1032599
  _41 = MIN_EXPR <_42, 4294967295>;
  # DEBUG __a => NULL
  # DEBUG __b => NULL
  # DEBUG NewCapacity => _41
  _4 = _41 * 16;
  # DEBUG Sz => _4
  Result_69 = malloc (_4);
  # DEBUG Result => Result_69
  if (Result_69 == 0B)
    goto <bb 5>; [19.86%]
  else
    goto <bb 6>; [80.14%]

  <bb 5> [2.98%]:
  llvm::report_bad_alloc_error ("Allocation failed", 1);
...

so I can't see a vectorization in the function in 7.3.0 either.
Can you please verify that you have vanilla 7.3.0 release?


More information about the Gcc-bugs mailing list