From c01ae2ab6b227e21835d128c90e974dce4604be9 Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Wed, 7 Apr 2021 13:17:05 +0200 Subject: [PATCH] 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. --- gcc/testsuite/gcc.dg/torture/pr99954.c | 30 ++++++++++++++++++++++++++ gcc/tree-loop-distribution.c | 17 +++++++++++++-- 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr99954.c 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; } -- 2.47.2