This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/36701] [4.4 Regression] unaligned access in gcc.c-torture/execute/complex-7.c



------- Comment #9 from hjl dot tools at gmail dot com  2008-07-08 19:55 -------
When emit_group_store allocates stack temp to copy from register
to stack, it should use the mode with the largest alignment. Does
this patch make sense?

--- expr.c.align        2008-07-02 11:56:29.000000000 -0700
+++ expr.c      2008-07-08 12:48:40.000000000 -0700
@@ -2074,10 +2074,28 @@ emit_group_store (rtx orig_dst, rtx src,
          else
            {
              gcc_assert (bytepos == 0 && XVECLEN (src, 0));
-             dest = assign_stack_temp (GET_MODE (dest),
-                                       GET_MODE_SIZE (GET_MODE (dest)), 0);
-             emit_move_insn (adjust_address (dest, GET_MODE (tmps[i]),
bytepos),
-                             tmps[i]);
+             enum machine_mode dest_mode = GET_MODE (dest);
+             enum machine_mode tmp_mode = GET_MODE (tmps[i]);
+
+             if (GET_MODE_ALIGNMENT (dest_mode)
+                 >= GET_MODE_ALIGNMENT (tmp_mode))
+               {
+                 dest = assign_stack_temp (dest_mode,
+                                           GET_MODE_SIZE (dest_mode),
+                                           0);
+                 emit_move_insn (adjust_address (dest,
+                                                 tmp_mode,
+                                                 bytepos),
+                                 tmps[i]);
+               }
+             else
+               {
+                 dest = assign_stack_temp (tmp_mode,
+                                           GET_MODE_SIZE (dest_mode),
+                                           0);
+                 emit_move_insn (dest, tmps[i]);
+                 dest = adjust_address (dest, dest_mode, bytepos);
+               }
              dst = dest;
              break;
            }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36701


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]