view gcc/testsuite/gcc.dg/tree-ssa/calloc-5.c @ 152:2b5abeee2509

update gcc11
author anatofuz
date Mon, 25 May 2020 07:50:57 +0900
parents 1830386684a0
children
line wrap: on
line source

/* PR tree-optimization/83821 - local aggregate initialization defeats
   strlen optimization
   Verify that with DSE disabled, a memset() call to zero out a subregion
   of memory allocated by calloc() is not eliminated after a non-zero byte
   is written into it using memset() in between the two calls.
   { dg-do compile }
   { dg-options "-O2 -fno-tree-dse -fdump-tree-optimized" } */

char* keep_memset_calls (void)
{
  char *p = __builtin_calloc (12, 1);

  __builtin_memset (p + 5, 1, 2);   /* dead store (not eliminated) */

  __builtin_memset (p, 0, 12);      /* must not be eliminated */

  return p;
}

/* { dg-final { scan-tree-dump-not "malloc" "optimized" } }
   { dg-final { scan-tree-dump-times "_calloc \\\(" 1 "optimized" } }
   { dg-final { scan-tree-dump-times "_memset \\\(" 2 "optimized" } } */