https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120201
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Drea Pinski from comment #9)
> Comment on attachment 64412 [details]
> A patch
>
> That is wrong. The lhs of load should not make a difference.
The code in question is
new_stmt = gimple_build_assign (NULL_TREE, srcmem);
srcmem
= make_ssa_name (TREE_TYPE (srcmem), new_stmt);
gimple_assign_set_lhs (new_stmt, srcmem);
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gimple_set_location (new_stmt, loc);
gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
where srcmem is unaligned. The current GCC generates
Breakpoint 2, gimple_fold_builtin_memory_op (gsi=0x7fffffffc820,
dest=0x7fffe95415d8, src=0x7fffe9541420, code=BUILT_IN_MEMCPY)
at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-fold.cc:1030
1030 new_stmt = gimple_build_assign (NULL_TREE,
srcmem);
(gdb) call debug (srcmem)
<mem_ref 0x7fffe9537fc8
type <vector_type 0x7fffe953c2a0
type <integer_type 0x7fffe953cf18 public unsigned QI
size <integer_cst 0x7fffe961b3c0 constant 8>
unit-size <integer_cst 0x7fffe961b3d8 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953cf18 precision:8 min <integer_cst 0x7fffe953b660 0> max <integer_cst
0x7fffe953b648 255>>
unsigned V64QI
size <integer_cst 0x7fffe961b9d8 constant 512>
unit-size <integer_cst 0x7fffe9792048 constant 64>
user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953c498 nunits:64>
arg:0 <ssa_name 0x7fffe9541420
type <pointer_type 0x7fffe962a930 type <real_type 0x7fffe962a2a0 float>
sizes-gimplified unsigned DI
size <integer_cst 0x7fffe961b2d0 constant 64>
unit-size <integer_cst 0x7fffe961b2e8 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe962a930>
def_stmt _3 = &transforms[face][0];
version:3>
arg:1 <integer_cst 0x7fffe953b630 type <pointer_type 0x7fffe953ce70>
constant 0>>
(gdb) next
1032 = make_ssa_name (TREE_TYPE (srcmem),
new_stmt);
(gdb)
1033 gimple_assign_set_lhs (new_stmt, srcmem);
(gdb) call debug (srcmem)
<ssa_name 0x7fffe9541840
type <vector_type 0x7fffe953c498
type <integer_type 0x7fffe953cf18 public unsigned QI
size <integer_cst 0x7fffe961b3c0 constant 8>
unit-size <integer_cst 0x7fffe961b3d8 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953cf18 precision:8 min <integer_cst 0x7fffe953b660 0> max <integer_cst
0x7fffe953b648 255>>
unsigned V64QI
size <integer_cst 0x7fffe961b9d8 constant 512>
unit-size <integer_cst 0x7fffe9792048 constant 64>
align:512 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953c498 nunits:64>
def_stmt = MEM <vector(64) unsigned char> [(char * {ref-all})_3];
version:7>
(gdb) next
1034 gimple_set_vuse (new_stmt, gimple_vuse
(stmt));
(gdb)
1035 gimple_set_location (new_stmt, loc);
(gdb)
1036 gsi_insert_before (gsi, new_stmt,
GSI_SAME_STMT);
(gdb) call debug (new_stmt)
_7 = MEM <vector(64) unsigned char> [(char * {ref-all})_3];
(gdb)
srcmem alignment changed from 8 to 512. It can't be right.
--- Comment #11 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Drea Pinski from comment #9)
> Comment on attachment 64412 [details]
> A patch
>
> That is wrong. The lhs of load should not make a difference.
The code in question is
new_stmt = gimple_build_assign (NULL_TREE, srcmem);
srcmem
= make_ssa_name (TREE_TYPE (srcmem), new_stmt);
gimple_assign_set_lhs (new_stmt, srcmem);
gimple_set_vuse (new_stmt, gimple_vuse (stmt));
gimple_set_location (new_stmt, loc);
gsi_insert_before (gsi, new_stmt, GSI_SAME_STMT);
where srcmem is unaligned. The current GCC generates
Breakpoint 2, gimple_fold_builtin_memory_op (gsi=0x7fffffffc820,
dest=0x7fffe95415d8, src=0x7fffe9541420, code=BUILT_IN_MEMCPY)
at /export/gnu/import/git/gitlab/x86-gcc/gcc/gimple-fold.cc:1030
1030 new_stmt = gimple_build_assign (NULL_TREE,
srcmem);
(gdb) call debug (srcmem)
<mem_ref 0x7fffe9537fc8
type <vector_type 0x7fffe953c2a0
type <integer_type 0x7fffe953cf18 public unsigned QI
size <integer_cst 0x7fffe961b3c0 constant 8>
unit-size <integer_cst 0x7fffe961b3d8 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953cf18 precision:8 min <integer_cst 0x7fffe953b660 0> max <integer_cst
0x7fffe953b648 255>>
unsigned V64QI
size <integer_cst 0x7fffe961b9d8 constant 512>
unit-size <integer_cst 0x7fffe9792048 constant 64>
user align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953c498 nunits:64>
arg:0 <ssa_name 0x7fffe9541420
type <pointer_type 0x7fffe962a930 type <real_type 0x7fffe962a2a0 float>
sizes-gimplified unsigned DI
size <integer_cst 0x7fffe961b2d0 constant 64>
unit-size <integer_cst 0x7fffe961b2e8 constant 8>
align:64 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe962a930>
def_stmt _3 = &transforms[face][0];
version:3>
arg:1 <integer_cst 0x7fffe953b630 type <pointer_type 0x7fffe953ce70>
constant 0>>
(gdb) next
1032 = make_ssa_name (TREE_TYPE (srcmem),
new_stmt);
(gdb)
1033 gimple_assign_set_lhs (new_stmt, srcmem);
(gdb) call debug (srcmem)
<ssa_name 0x7fffe9541840
type <vector_type 0x7fffe953c498
type <integer_type 0x7fffe953cf18 public unsigned QI
size <integer_cst 0x7fffe961b3c0 constant 8>
unit-size <integer_cst 0x7fffe961b3d8 constant 1>
align:8 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953cf18 precision:8 min <integer_cst 0x7fffe953b660 0> max <integer_cst
0x7fffe953b648 255>>
unsigned V64QI
size <integer_cst 0x7fffe961b9d8 constant 512>
unit-size <integer_cst 0x7fffe9792048 constant 64>
align:512 warn_if_not_align:0 symtab:0 alias-set -1 canonical-type
0x7fffe953c498 nunits:64>
def_stmt = MEM <vector(64) unsigned char> [(char * {ref-all})_3];
version:7>
(gdb) next
1034 gimple_set_vuse (new_stmt, gimple_vuse
(stmt));
(gdb)
1035 gimple_set_location (new_stmt, loc);
(gdb)
1036 gsi_insert_before (gsi, new_stmt,
GSI_SAME_STMT);
(gdb) call debug (new_stmt)
_7 = MEM <vector(64) unsigned char> [(char * {ref-all})_3];
(gdb)
srcmem alignment changed from 8 to 512. It can't be right.