* [Aarch64] Fix alignment of neon loads & stores in gimple
@ 2021-10-25 12:00 Andre Vieira (lists)
2021-10-25 14:44 ` Richard Sandiford
0 siblings, 1 reply; 2+ messages in thread
From: Andre Vieira (lists) @ 2021-10-25 12:00 UTC (permalink / raw)
To: gcc-patches; +Cc: Kyrylo Tkachov, Richard Sandiford
[-- Attachment #1: Type: text/plain, Size: 431 bytes --]
Hi,
This fixes the alignment on the memory access type for neon loads &
stores in the gimple lowering. Bootstrap ubsan on aarch64 builds again
with this change.
2021-10-25 Andre Vieira <andre.simoesdiasvieira@arm.com>
gcc/ChangeLog:
* config/aarch64/aarch64-builtins.c
(aarch64_general_gimple_fold_builtin): Fix memory access
type alignment.
Is this OK for trunk?
Kind regards,
Andre
[-- Attachment #2: fix_neon_mem_align.patch --]
[-- Type: text/plain, Size: 1597 bytes --]
diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
index a815e4cfbccab692ca688ba87c71b06c304abbfb..f5436baf5f8a65c340e05faa491d86a7847c37d3 100644
--- a/gcc/config/aarch64/aarch64-builtins.c
+++ b/gcc/config/aarch64/aarch64-builtins.c
@@ -2490,12 +2490,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt,
gimple_seq stmts = NULL;
tree base = gimple_convert (&stmts, elt_ptr_type,
args[0]);
+ /* Use element type alignment. */
+ tree access_type
+ = build_aligned_type (simd_type.itype,
+ TYPE_ALIGN (TREE_TYPE (simd_type.itype)));
if (stmts)
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
new_stmt
= gimple_build_assign (gimple_get_lhs (stmt),
fold_build2 (MEM_REF,
- simd_type.itype,
+ access_type,
base, zero));
}
break;
@@ -2512,13 +2516,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt,
gimple_seq stmts = NULL;
tree base = gimple_convert (&stmts, elt_ptr_type,
args[0]);
+ /* Use element type alignment. */
+ tree access_type
+ = build_aligned_type (simd_type.itype,
+ TYPE_ALIGN (TREE_TYPE (simd_type.itype)));
if (stmts)
gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
new_stmt
- = gimple_build_assign (fold_build2 (MEM_REF,
- simd_type.itype,
- base,
- zero), args[1]);
+ = gimple_build_assign (fold_build2 (MEM_REF, access_type,
+ base, zero),
+ args[1]);
}
break;
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Aarch64] Fix alignment of neon loads & stores in gimple
2021-10-25 12:00 [Aarch64] Fix alignment of neon loads & stores in gimple Andre Vieira (lists)
@ 2021-10-25 14:44 ` Richard Sandiford
0 siblings, 0 replies; 2+ messages in thread
From: Richard Sandiford @ 2021-10-25 14:44 UTC (permalink / raw)
To: Andre Vieira (lists); +Cc: gcc-patches, Kyrylo Tkachov
"Andre Vieira (lists)" <andre.simoesdiasvieira@arm.com> writes:
> Hi,
>
> This fixes the alignment on the memory access type for neon loads &
> stores in the gimple lowering. Bootstrap ubsan on aarch64 builds again
> with this change.
>
>
> 2021-10-25 Andre Vieira <andre.simoesdiasvieira@arm.com>
>
> gcc/ChangeLog:
>
> * config/aarch64/aarch64-builtins.c
> (aarch64_general_gimple_fold_builtin): Fix memory access
> type alignment.
>
>
> Is this OK for trunk?
>
> Kind regards,
> Andre
>
> diff --git a/gcc/config/aarch64/aarch64-builtins.c b/gcc/config/aarch64/aarch64-builtins.c
> index a815e4cfbccab692ca688ba87c71b06c304abbfb..f5436baf5f8a65c340e05faa491d86a7847c37d3 100644
> --- a/gcc/config/aarch64/aarch64-builtins.c
> +++ b/gcc/config/aarch64/aarch64-builtins.c
> @@ -2490,12 +2490,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt,
> gimple_seq stmts = NULL;
> tree base = gimple_convert (&stmts, elt_ptr_type,
> args[0]);
> + /* Use element type alignment. */
> + tree access_type
> + = build_aligned_type (simd_type.itype,
> + TYPE_ALIGN (TREE_TYPE (simd_type.itype)));
Guess this is slightly simpler as TYPE_ALIGN (simd_type.eltype)
but either's fine.
OK with or without that change.
Thanks,
Richard
> if (stmts)
> gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
> new_stmt
> = gimple_build_assign (gimple_get_lhs (stmt),
> fold_build2 (MEM_REF,
> - simd_type.itype,
> + access_type,
> base, zero));
> }
> break;
> @@ -2512,13 +2516,16 @@ aarch64_general_gimple_fold_builtin (unsigned int fcode, gcall *stmt,
> gimple_seq stmts = NULL;
> tree base = gimple_convert (&stmts, elt_ptr_type,
> args[0]);
> + /* Use element type alignment. */
> + tree access_type
> + = build_aligned_type (simd_type.itype,
> + TYPE_ALIGN (TREE_TYPE (simd_type.itype)));
> if (stmts)
> gsi_insert_seq_before (gsi, stmts, GSI_SAME_STMT);
> new_stmt
> - = gimple_build_assign (fold_build2 (MEM_REF,
> - simd_type.itype,
> - base,
> - zero), args[1]);
> + = gimple_build_assign (fold_build2 (MEM_REF, access_type,
> + base, zero),
> + args[1]);
> }
> break;
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-25 14:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-25 12:00 [Aarch64] Fix alignment of neon loads & stores in gimple Andre Vieira (lists)
2021-10-25 14:44 ` Richard Sandiford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).