diff options
author | Andreas Krebbel <krebbel1@de.ibm.com> | 2006-04-25 12:11:25 +0000 |
---|---|---|
committer | Andreas Krebbel <krebbel@gcc.gnu.org> | 2006-04-25 12:11:25 +0000 |
commit | 495db1a1155904059e4239dc124c85717245d761 (patch) | |
tree | d52d7694a2925756c7a06010431f2e6f09f3fa68 /gcc | |
parent | 6d75cd5f57c4d23cdbd5acf9da32daf5265c07af (diff) | |
download | gcc-495db1a1155904059e4239dc124c85717245d761.zip gcc-495db1a1155904059e4239dc124c85717245d761.tar.gz gcc-495db1a1155904059e4239dc124c85717245d761.tar.bz2 |
expmed.c (store_bit_field): Handle paradoxical subregs on big endian machines.
2006-04-25 Andreas Krebbel <krebbel1@de.ibm.com>
* expmed.c (store_bit_field): Handle paradoxical subregs on big endian
machines.
2006-04-25 Andreas Krebbel <krebbel1@de.ibm.com>
* gcc.dg/20060425-1.c: New testcase.
From-SVN: r113248
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/expmed.c | 20 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/20060425-1.c | 38 |
4 files changed, 66 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 2d88406..eb38288 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2006-04-25 Andreas Krebbel <krebbel1@de.ibm.com> + + * expmed.c (store_bit_field): Handle paradoxical subregs on big endian + machines. + 2006-04-25 Bernd Schmidt <bernd.schmidt@analog.com> * genmodes.c (make_vector_mode): Allow making VECTOR_MODE_INT of a diff --git a/gcc/expmed.c b/gcc/expmed.c index a4396c2..31b8241 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -363,7 +363,25 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, meaningful at a much higher level; when structures are copied between memory and regs, the higher-numbered regs always get higher addresses. */ - bitnum += SUBREG_BYTE (op0) * BITS_PER_UNIT; + int inner_mode_size = GET_MODE_SIZE (GET_MODE (SUBREG_REG (op0))); + int outer_mode_size = GET_MODE_SIZE (GET_MODE (op0)); + + byte_offset = 0; + + /* Paradoxical subregs need special handling on big endian machines. */ + if (SUBREG_BYTE (op0) == 0 && inner_mode_size < outer_mode_size) + { + int difference = inner_mode_size - outer_mode_size; + + if (WORDS_BIG_ENDIAN) + byte_offset += (difference / UNITS_PER_WORD) * UNITS_PER_WORD; + if (BYTES_BIG_ENDIAN) + byte_offset += difference % UNITS_PER_WORD; + } + else + byte_offset = SUBREG_BYTE (op0); + + bitnum += byte_offset * BITS_PER_UNIT; op0 = SUBREG_REG (op0); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3392b96..f29ab27 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2006-04-25 Andreas Krebbel <krebbel1@de.ibm.com> + + * gcc.dg/20060425-1.c: New testcase. + 2006-04-25 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/26865 diff --git a/gcc/testsuite/gcc.dg/20060425-1.c b/gcc/testsuite/gcc.dg/20060425-1.c new file mode 100644 index 0000000..7d899b2 --- /dev/null +++ b/gcc/testsuite/gcc.dg/20060425-1.c @@ -0,0 +1,38 @@ +/* { dg-do run } */ +/* { dg-options "-O1" } */ + +/* This failed because if conversion didn't handle insv patterns properly. */ + +void abort (void); + +union y +{ + int a; + unsigned short b; +}; + +void __attribute__ ((noinline)) +bar (unsigned short u, union y v) +{ + if (u != 1) + abort (); +} + +void __attribute__ ((noinline)) +foo (int check) +{ + union y x; + + if (check != 0) + x.b = 1; + else + x.b = 2; + bar (x.b, x); +} + +int +main () +{ + foo (1); + return 0; +} |