https://gcc.gnu.org/g:7b02b8f65ef60be77f3f93945e2a6b463edaa0aa
commit r15-7264-g7b02b8f65ef60be77f3f93945e2a6b463edaa0aa Author: Richard Biener <rguent...@suse.de> Date: Wed Jan 29 08:58:39 2025 +0100 middle-end/118684 - fix fallout of wrong stack local alignment fix When we expand BIT_FIELD_REF <x_2(D), 8, 8> we can end up creating a stack local, running into the fix. But get_object_alignment will return 8 for any SSA_NAME because that's not an "object" we handle. Deal with handled components on registers by singling out SSA_NAME bases, using their type alignment instead of get_object_alignment (I considered "robustifying" get_object_alignment, but decided not to at this point). This fixes an ICE on gcc.dg/pr41123.c on arm as reported by the CI. PR middle-end/118684 * expr.cc (expand_expr_real_1): When creating a stack local during expansion of a handled component, when the base is a SSA_NAME use its type alignment and avoid calling get_object_alignment. * gcc.dg/pr118684.c: Require automatic_stack_alignment. Diff: --- gcc/expr.cc | 4 +++- gcc/testsuite/gcc.dg/pr118684.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/expr.cc b/gcc/expr.cc index 95f41f69fcf2..7f3149b85eec 100644 --- a/gcc/expr.cc +++ b/gcc/expr.cc @@ -12152,7 +12152,9 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode tmode, if (!poly_int_tree_p (TYPE_SIZE_UNIT (TREE_TYPE (tem)), &size)) size = max_int_size_in_bytes (TREE_TYPE (tem)); memloc = assign_stack_local (TYPE_MODE (TREE_TYPE (tem)), size, - get_object_alignment (tem)); + TREE_CODE (tem) == SSA_NAME + ? TYPE_ALIGN (TREE_TYPE (tem)) + : get_object_alignment (tem)); emit_move_insn (memloc, op0); op0 = memloc; clear_mem_expr = true; diff --git a/gcc/testsuite/gcc.dg/pr118684.c b/gcc/testsuite/gcc.dg/pr118684.c index 08cc24dc0616..28fd76e366dc 100644 --- a/gcc/testsuite/gcc.dg/pr118684.c +++ b/gcc/testsuite/gcc.dg/pr118684.c @@ -1,4 +1,4 @@ -/* { dg-do run } */ +/* { dg-do run { target automatic_stack_alignment } } */ /* { dg-options "-O2" } */ typedef int v4si __attribute__((vector_size(16)));