From: Richard Biener Date: Wed, 7 Apr 2021 11:17:05 +0000 (+0200) Subject: tree-optimization/99954 - fix loop distribution memcpy classification X-Git-Tag: basepoints/gcc-12~230 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c01ae2ab6b227e21835d128c90e974dce4604be9;p=thirdparty%2Fgcc.git tree-optimization/99954 - fix loop distribution memcpy classification 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 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. --- diff --git a/gcc/testsuite/gcc.dg/torture/pr99954.c b/gcc/testsuite/gcc.dg/torture/pr99954.c new file mode 100644 index 000000000000..7d4470359125 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr99954.c @@ -0,0 +1,30 @@ +/* { dg-do run } */ + +#include + +#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; ibuiltin = alloc_builtin (dst_dr, src_dr, base, src_base, size); - partition->kind = PKIND_MEMCPY; + partition->kind = PKIND_MEMMOVE; return; }