This fixes bogus classification of a copy as memcpy. We cannot use plain dependence analysis to decide between memcpy and memmove when it computes no dependence. Instead we have to try harder later which the patch does for the gcc.dg/tree-ssa/ldist-24.c testcase by resorting to tree-affine to compute the difference between src and dest and compare against the copy size. 2021-04-07 Richard Biener <rguenther@suse.de> PR tree-optimization/99954 * tree-loop-distribution.c: Include tree-affine.h. (generate_memcpy_builtin): Try using tree-affine to prove non-overlap. (loop_distribution::classify_builtin_ldst): Always classify as PKIND_MEMMOVE. * gcc.dg/torture/pr99954.c: New testcase.
31 lines
585 B
C
31 lines
585 B
C
/* { dg-do run } */
|
|
|
|
#include <assert.h>
|
|
|
|
#define CONTAINER_KIND union
|
|
|
|
typedef CONTAINER_KIND container { int value; } container;
|
|
|
|
void move(container* end, container* start) {
|
|
container* p;
|
|
for (p = end; p > start; p--) {
|
|
(p)->value = (p-1)->value;
|
|
}
|
|
}
|
|
|
|
#define N 100
|
|
|
|
int main(int argc, char* argv[]) {
|
|
container vals[N];
|
|
int i;
|
|
for (i=0; i<N; i++) {
|
|
vals[i].value = argc + i;
|
|
}
|
|
move(&vals[N-1], &vals[0]);
|
|
assert(vals[0].value == argc + 0);
|
|
for (i=1; i<N; i++) {
|
|
assert(vals[i].value == argc + i - 1);
|
|
}
|
|
return 0;
|
|
}
|