[Bug c/98658] Loop idiom recognization for memcpy/memmove

2021-01-13 Thread david.bolvansky at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98658

--- Comment #3 from Dávid Bolvanský  ---
Yes, runtime check.

[Bug c/98658] Loop idiom recognization for memcpy/memmove

2021-01-13 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98658

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|UNCONFIRMED |RESOLVED

--- Comment #2 from Richard Biener  ---
it's because

(gdb) p debug_data_dependence_relation (ddr)
(Data Dep: 
#(Data Ref: 
#  bb: 3 
#  stmt: _1 = *s_19;
#  ref: *s_19;
#  base_object: *s_7(D);
#  Access function 0: {0B, +, 4}_1
#)
#(Data Ref: 
#  bb: 3 
#  stmt: *d_18 = _1;
#  ref: *d_18;
#  base_object: *d_6(D);
#  Access function 0: {0B, +, 4}_1
#)
(don't know)
)

and we say

  /* Can't do memmove in case of unknown dependence or dependence without
 classical distance vector.  */
  if (DDR_ARE_DEPENDENT (ddr) == chrec_dont_know
  || DDR_NUM_DIST_VECTS (ddr) == 0)
return;

which is because we need to check the depdenence is not backwards
(*s++ loads an earlier stored value).  I don't see how that is
guaranteed in the 'copy' case and ICC either miscompiles this
or has a runtime check doing the memcpy only conditionally.

[Bug c/98658] Loop idiom recognization for memcpy/memmove

2021-01-13 Thread david.bolvansky at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98658

--- Comment #1 from Dávid Bolvanský  ---
ICC produces memcpy:
https://godbolt.org/z/oKxxTM