This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
expmed.c (store_bit_field): Fix builtin_memcpy/ADDRESSOF problem.
- To: egcs-patches at cygnus dot com
- Subject: expmed.c (store_bit_field): Fix builtin_memcpy/ADDRESSOF problem.
- From: Jim Wilson <wilson at cygnus dot com>
- Date: Wed, 21 Oct 1998 19:31:50 -0700
I just installed this patch. This patch fixes a problem that can occur when
purge_addressof calls store_bit_field. We accidentally copied a destination,
causing one byte store to go into a temporary, and then be optimized away
as unused.
Here is a testcase. The assembly output at -O -S only has 7 byte store
instructions instead of 8.
double c (void* a) {
double d;
__builtin_memcpy (&d, a, sizeof (double));
return d;
}
Wed Oct 21 19:23:59 1998 Jim Wilson <wilson@cygnus.com>
* expmed.c (store_bit_field): If need to add a SUBREG, then remove
existing SUBREG if we can, otherwise abort.
Index: expmed.c
===================================================================
RCS file: /cvs/cvsfiles/devo/gcc/expmed.c,v
retrieving revision 1.126
diff -p -r1.126 expmed.c
*** expmed.c 1998/10/14 06:09:56 1.126
--- expmed.c 1998/10/19 23:39:44
*************** store_bit_field (str_rtx, bitsize, bitnu
*** 423,429 ****
|| GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD)
{
if (GET_CODE (op0) != REG)
! op0 = copy_to_reg (op0);
op0 = gen_rtx_SUBREG (mode_for_size (BITS_PER_WORD, MODE_INT, 0),
op0, offset);
}
--- 423,440 ----
|| GET_MODE_SIZE (GET_MODE (op0)) > UNITS_PER_WORD)
{
if (GET_CODE (op0) != REG)
! {
! /* Since this is a destination (lvalue), we can't copy it to a
! pseudo. We can trivially remove a SUBREG that does not
! change the size of the operand. Such a SUBREG may have been
! added above. Otherwise, abort. */
! if (GET_CODE (op0) == SUBREG
! && (GET_MODE_SIZE (GET_MODE (op0))
! == GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0)))))
! op0 = SUBREG_REG (op0);
! else
! abort ();
! }
op0 = gen_rtx_SUBREG (mode_for_size (BITS_PER_WORD, MODE_INT, 0),
op0, offset);
}