From: Daniel Jacobowitz Date: Sat, 23 Feb 2008 15:45:03 +0000 (+0000) Subject: expmed.c (extract_bit_field): Always use adjust_address for MEM. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8ddcfde143971709cc4c45d0c9de1e3b511b77aa;p=gcc.git expmed.c (extract_bit_field): Always use adjust_address for MEM. * expmed.c (extract_bit_field): Always use adjust_address for MEM. * gcc.c-torture/execute/20080222-1.c: New test. From-SVN: r132573 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 9a90b880a2e..f33f1d352d4 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2008-02-23 Daniel Jacobowitz + + * expmed.c (extract_bit_field): Always use adjust_address for MEM. + 2008-02-23 Uros Bizjak PR target/22076 diff --git a/gcc/expmed.c b/gcc/expmed.c index 09a58dedba2..04071d375ed 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -1339,18 +1339,15 @@ extract_bit_field_1 (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, || (offset * BITS_PER_UNIT % bitsize == 0 && MEM_ALIGN (op0) % bitsize == 0))))) { - if (mode1 != GET_MODE (op0)) + if (MEM_P (op0)) + op0 = adjust_address (op0, mode1, offset); + else if (mode1 != GET_MODE (op0)) { - if (MEM_P (op0)) - op0 = adjust_address (op0, mode1, offset); - else - { - rtx sub = simplify_gen_subreg (mode1, op0, GET_MODE (op0), - byte_offset); - if (sub == NULL) - goto no_subreg_mode_swap; - op0 = sub; - } + rtx sub = simplify_gen_subreg (mode1, op0, GET_MODE (op0), + byte_offset); + if (sub == NULL) + goto no_subreg_mode_swap; + op0 = sub; } if (mode1 != mode) return convert_to_mode (tmode, op0, unsignedp); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 21776c423cd..b111ef4da71 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2008-02-23 Daniel Jacobowitz + + * gcc.c-torture/execute/20080222-1.c: New test. + 2008-02-23 Uros Bizjak PR target/22076 diff --git a/gcc/testsuite/gcc.c-torture/execute/20080222-1.c b/gcc/testsuite/gcc.c-torture/execute/20080222-1.c new file mode 100644 index 00000000000..6db83ccdf90 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20080222-1.c @@ -0,0 +1,22 @@ +extern void abort (void); + +struct container +{ + unsigned char data[1]; +}; + +unsigned char space[6] = {1, 2, 3, 4, 5, 6}; + +int +foo (struct container *p) +{ + return p->data[4]; +} + +int +main () +{ + if (foo ((struct container *) space) != 5) + abort (); + return 0; +}