From 03ca1672e4d910a7829d8680860fe9aa0fbcfbaf Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 11 Mar 2004 22:53:52 +0000 Subject: [PATCH] re PR target/14262 (Structure size computed wrong) PR target/14262 * calls.c (load_register_parameters): If BLOCK_REG_PADDING is not defined, pass small BLKmode values in registers in the low-order part. * gcc.dg/20040305-2.c: New test. From-SVN: r79348 --- gcc/ChangeLog | 6 +++++ gcc/calls.c | 9 ++++--- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/20040305-2.c | 45 +++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 3 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/20040305-2.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 8526cfb6c883..66813dd26c1f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-03-11 Ulrich Weigand + + PR target/14262 + * calls.c (load_register_parameters): If BLOCK_REG_PADDING is not + defined, pass small BLKmode values in registers in the low-order part. + 2004-03-11 Ulrich Weigand * combine.c (if_then_else_cond): Check for NULL return value of diff --git a/gcc/calls.c b/gcc/calls.c index 4bfcde4f6e1b..29c06aa47723 100644 --- a/gcc/calls.c +++ b/gcc/calls.c @@ -1675,10 +1675,14 @@ load_register_parameters (struct arg_data *args, int num_actuals, { rtx mem = validize_mem (args[i].value); -#ifdef BLOCK_REG_PADDING /* Handle a BLKmode that needs shifting. */ if (nregs == 1 && size < UNITS_PER_WORD - && args[i].locate.where_pad == downward) +#ifdef BLOCK_REG_PADDING + && args[i].locate.where_pad == downward +#else + && BYTES_BIG_ENDIAN +#endif + ) { rtx tem = operand_subword_force (mem, 0, args[i].mode); rtx ri = gen_rtx_REG (word_mode, REGNO (reg)); @@ -1693,7 +1697,6 @@ load_register_parameters (struct arg_data *args, int num_actuals, emit_move_insn (ri, x); } else -#endif move_block_to_reg (REGNO (reg), mem, nregs, args[i].mode); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index da07a0408e90..fe5bb99a066c 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-11 Ulrich Weigand + + PR target/14262 + * gcc.dg/20040305-2.c: New test. + 2004-03-11 Ulrich Weigand * gcc.dg/20040310-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/20040305-2.c b/gcc/testsuite/gcc.dg/20040305-2.c new file mode 100644 index 000000000000..4a3ef9a19b0a --- /dev/null +++ b/gcc/testsuite/gcc.dg/20040305-2.c @@ -0,0 +1,45 @@ +/* PR target/14262 */ +/* { dg-do run } */ + +typedef char ACS; +typedef char LSM; +typedef char PANEL; +typedef char DRIVE; +typedef struct { + ACS acs; + LSM lsm; +} LSMID; +typedef struct { + LSMID lsm_id; + PANEL panel; +} PANELID; +typedef struct { + PANELID panel_id; + DRIVE drive; +} DRIVEID; + +void sub (DRIVEID driveid) +{ + if (driveid.drive != 1) + abort (); + if (driveid.panel_id.panel != 2) + abort (); + if (driveid.panel_id.lsm_id.lsm != 3) + abort (); + if (driveid.panel_id.lsm_id.acs != 4) + abort (); +} + +int main(void) +{ + DRIVEID driveid; + + driveid.drive = 1; + driveid.panel_id.panel = 2; + driveid.panel_id.lsm_id.lsm = 3; + driveid.panel_id.lsm_id.acs = 4; + + sub(driveid); +} + +