On Mon, 27 Sep 2021, sunil.k.pandey wrote:

> On Linux/x86_64,
> 
> d06dc8a2c73735e9496f434787ba4c93ceee5eea is the first bad commit
> commit d06dc8a2c73735e9496f434787ba4c93ceee5eea
> Author: Richard Biener <rguent...@suse.de>
> Date:   Mon Sep 27 13:36:12 2021 +0200
> 
>     middle-end/102450 - avoid type_for_size for non-existing modes
> 
> caused
> 
> FAIL: gcc.dg/out-of-bounds-1.c  (test for warnings, line 12)
> FAIL: gcc.dg/pr78408-1.c scan-tree-dump-times fab1 "after previous" 17
> FAIL: gcc.dg/strlenopt-13.c scan-tree-dump-times strlen1 "memcpy \\(" 7

After the change the new memcpy inlining limit using MOVE_MAX * MOVE_RATIO
comes into play and ends up using an OImode move which previously was
disregarded as there's no __int256 standard type in the frontend
(but now we build such type anyway after verifying the mode exists and
it has move support).

For example gcc.dg/out-of-bounds-1.c which looks like

void ProjectOverlay(const float localTextureAxis[2], char *lump)
{
   const void *d = &localTextureAxis;
   int size = sizeof(float)*8 ;
   __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" } 
*/
}

gets turned into

        movq    %rdi, -8(%rsp)
        vmovdqu64       -8(%rsp), %ymm31
        vmovdqu64       %ymm31, (%rsi)

which I guess is good but then the diagnostic is no longer emitted
because -Wstringop-overread only applies to the builtin.  Usually
we avoid the folding in such a case but

              /* Detect out-of-bounds accesses without issuing warnings.
                 Avoid folding out-of-bounds copies but to avoid false
                 positives for unreachable code defer warning until after
                 DCE has worked its magic.
                 -Wrestrict is still diagnosed.  */
              if (int warning = check_bounds_or_overlap (as_a <gcall 
*>(stmt),
                                                         dest, src, len, 
len,
                                                         false, false))
                if (warning != OPT_Wrestrict)
                  return false;

does not seem to trigger here.  Changing the testcase to

void ProjectOverlay(const float localTextureAxis[2], char *lump)
{
   const void *d = &localTextureAxis;
   int size = sizeof(float)*4 ;
   __builtin_memcpy( &lump[ 0 ], d, size );  /* { dg-warning "reading" } 
*/
}

also fails to warn.

Richard.

Reply via email to