This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch to fix unaligned access in float->union assignment
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: Richard Henderson <rth at redhat dot com>, Richard Sandiford <rsandifo at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Thu, 28 Nov 2002 15:12:57 +0000
- Subject: Re: Patch to fix unaligned access in float->union assignment
- Organization: SuperH UK Ltd.
The comment just above the code in question says:
/* If VALUE is a floating-point mode, access it as an integer of the
corresponding size. This can occur on a machine with 64 bit registers
that uses SFmode for float. This can also occur for unaligned float
structure fields. */
I think the problem hre is that word_mode is being used, which does not actually
guarantee us to get an onteger of the corresponding size. We should be using
int_mode_for_mode to get that.
--
--------------------------
SuperH (UK) Ltd.
2410 Aztec West / Almondsbury / BRISTOL / BS32 4QX
T:+44 1454 465658
Thu Nov 28 15:06:01 2002 J"orn Rennecke <joern.rennecke@superh.com>
* expmed.c (store_bit_field): Use int_mode_for_mode to find
corresponding mode of non-integer mode.
Index: expmed.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/expmed.c,v
retrieving revision 1.122.4.2
diff -p -r1.122.4.2 expmed.c
*** expmed.c 5 Nov 2002 19:11:53 -0000 1.122.4.2
--- expmed.c 28 Nov 2002 15:05:50 -0000
*************** store_bit_field (str_rtx, bitsize, bitnu
*** 535,541 ****
structure fields. */
if (GET_MODE_CLASS (GET_MODE (value)) != MODE_INT
&& GET_MODE_CLASS (GET_MODE (value)) != MODE_PARTIAL_INT)
! value = gen_lowpart (word_mode, value);
/* Now OFFSET is nonzero only if OP0 is memory
and is therefore always measured in bytes. */
--- 535,541 ----
structure fields. */
if (GET_MODE_CLASS (GET_MODE (value)) != MODE_INT
&& GET_MODE_CLASS (GET_MODE (value)) != MODE_PARTIAL_INT)
! value = gen_lowpart (int_mode_for_mode (GET_MODE (value), value));
/* Now OFFSET is nonzero only if OP0 is memory
and is therefore always measured in bytes. */