https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125977
Bug ID: 125977
Summary: emit_block_move_via_pattern/set_storage_via_setmem
don't check min_size == max_size
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hjl.tools at gmail dot com
Target Milestone: ---
For
#define MAX 16
void
foo (void *a, void *b, __SIZE_TYPE__ n)
{
if (n >= MAX && n <= MAX)
__builtin_memcpy (a, b, n);
}
and
#define MAX 16
void
foo (void *a, __SIZE_TYPE__ n)
{
if (n >= MAX && n <= MAX)
__builtin_memset (a, 0, n);
}
emit_block_move_via_pattern/set_storage_via_setmem don't check min_size ==
max_size.
When compiled with -O0, we get
(gdb) f 5
#5 0x00000000021e67e4 in emit_block_move_via_pattern (x=0x7fffe9401960,
y=0x7fffe9401a20, size=0x7fffe9401990, align=8, expected_align=8,
expected_size=-1, min_size=16, max_size=16, probable_max_size=16,
might_overlap=false)
at /export/gnu/import/git/gitlab/x86-gcc-test/gcc/expr.cc:2323
2323 if (maybe_expand_insn (code, nops, ops))
(gdb) pwd
Working directory /export/home/hjl/bugs/gcc/pr125968.
(gdb) call debug (size)
(mem/c:DI (plus:DI (reg/f:DI 93 virtual-stack-vars)
(const_int -24 [0xffffffffffffffe8])) [2 n+0 S8 A64])
(gdb)
and
(gdb) f 5
#5 0x00000000021ed479 in set_storage_via_setmem (object=0x7fffe94018e8,
size=0x7fffe9401858, val=0x7fffe9609490, align=8, expected_align=8,
expected_size=-1, min_size=16, max_size=16, probable_max_size=16)
at /export/gnu/import/git/gitlab/x86-gcc-test/gcc/expr.cc:4048
4048 if (maybe_expand_insn (code, nops, ops))
(gdb) call debug (size)
(mem/c:DI (plus:DI (reg/f:DI 93 virtual-stack-vars)
(const_int -16 [0xfffffffffffffff0])) [2 n+0 S8 A64])
(gdb)