1 /* PR 81908 - FAIL: gfortran.dg/alloc_comp_auto_array_2.f90 -O3 -g -m32 2 Test to verify that calls to memcpy et al. where the size is in a range 3 with just one valid value -- zero -- are eliminated. 4 { dg-do compile } 5 { dg-options "-O2 -Wall -fdump-tree-optimized" } */ 6 7 #define INT_MAX __INT_MAX__ 8 #define SHRT_MAX __SHRT_MAX__ 9 #define SIZE_MAX __SIZE_MAX__ 10 #define SSIZE_MAX (SIZE_MAX / 2) 11 12 typedef __PTRDIFF_TYPE__ ssize_t; 13 typedef __SIZE_TYPE__ size_t; 14 15 #define UNIQUE_FUNCNAME(func, line) test_ ## func ## _ ## line 16 #define FUNCNAME(func, line) UNIQUE_FUNCNAME (func, line) 17 18 #define AR(func, type, min, max, val) \ 19 void __attribute__ ((noclone, noinline)) \ 20 FUNCNAME (func, __LINE__) (char *d, const char *s, type n) \ 21 { \ 22 if ((type)min <= n && n <= (type)max) \ 23 n = val; \ 24 __builtin_ ## func (d, s, n); \ 25 } typedef void DummyType 26 27 AR (memcpy, short, 1, SHRT_MAX, 0); 28 AR (memcpy, int, 1, INT_MAX, 0); 29 AR (memcpy, size_t, 1, SSIZE_MAX, 0); 30 AR (memcpy, ssize_t, 1, SSIZE_MAX, 0); 31 32 AR (memmove, short, 1, SHRT_MAX, 0); 33 AR (memmove, int, 1, INT_MAX, 0); 34 AR (memmove, ssize_t, 1, SSIZE_MAX, 0); 35 AR (memmove, ssize_t, 1, SSIZE_MAX, 0); 36 37 AR (mempcpy, short, 1, SHRT_MAX, 0); 38 AR (mempcpy, int, 1, INT_MAX, 0); 39 AR (mempcpy, size_t, 1, SSIZE_MAX, 0); 40 AR (mempcpy, ssize_t, 1, SSIZE_MAX, 0); 41 42 /* { dg-final { scan-tree-dump-not "builtin_memcpy" "optimized" } } 43 { dg-final { scan-tree-dump-not "builtin_memmove" "optimized" } } 44 { dg-final { scan-tree-dump-not "builtin_mempcpy" "optimized" } } */ 45