https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118684

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2025-01-28
     Ever confirmed|0                           |1
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
           Keywords|                            |wrong-code

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The following fixes this.  Alternatively assign_temp could get an optional
alignment parameter.  Possibly assign_stack_local could get a variant with
type so we can share the size/mode compute.

diff --git a/gcc/expr.cc b/gcc/expr.cc
index a06411e1c27..95f41f69fcf 100644
--- a/gcc/expr.cc
+++ b/gcc/expr.cc
@@ -12148,7 +12148,11 @@ expand_expr_real_1 (tree exp, rtx target, machine_mode
tmode,
           and need be, put it there.  */
        else if (CONSTANT_P (op0) || (!MEM_P (op0) && must_force_mem))
          {
-           memloc = assign_temp (TREE_TYPE (tem), 1, 1);
+           poly_int64 size;
+           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));
            emit_move_insn (memloc, op0);
            op0 = memloc;
            clear_mem_expr = true;

Reply via email to