diff options
author | dalej <dalej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-16 05:52:46 +0000 |
---|---|---|
committer | dalej <dalej@138bc75d-0d04-0410-961f-82ee72b054a4> | 2005-11-16 05:52:46 +0000 |
commit | 1474439e910dcd0075945fa7201040eef1055893 (patch) | |
tree | 3fc699b8452c57de33ec8fef98831644d137d200 | |
parent | 2e436fa5516895e5eba9911e47e6f17dfcf61131 (diff) |
2005-11-15 Dale Johannesen <dalej@apple.com>apple/gcc-5248
* gcc.c-torture/execute/20051113-1.c: New.
2005-11-15 Dale Johannesen <dalej@apple.com>
* expmed.c (store_bit_field): Add offset unconditionally for
memory targets.
(extract_bit_field): Don't force extzv or extv operand into
a register if field is too big.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/apple-200511-release-branch@107066 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog.apple-ppc | 7 | ||||
-rw-r--r-- | gcc/expmed.c | 29 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog.apple-ppc | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/20051113-1.c | 72 |
4 files changed, 104 insertions, 8 deletions
diff --git a/gcc/ChangeLog.apple-ppc b/gcc/ChangeLog.apple-ppc index 5f5e05bbd22..3164be8e83a 100644 --- a/gcc/ChangeLog.apple-ppc +++ b/gcc/ChangeLog.apple-ppc @@ -1,5 +1,12 @@ 2005-11-15 Dale Johannesen <dalej@apple.com> + * expmed.c (store_bit_field): Add offset unconditionally for + memory targets. + (extract_bit_field): Don't force extzv or extv operand into + a register if field is too big. + +2005-11-15 Dale Johannesen <dalej@apple.com> + * cfghooks.c (split_block): Copy loop_father. * cfgloopmanip.c (create_loops_notes): Create preheaders. diff --git a/gcc/expmed.c b/gcc/expmed.c index e9142745853..b8399173623 100644 --- a/gcc/expmed.c +++ b/gcc/expmed.c @@ -438,14 +438,13 @@ store_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, || (offset * BITS_PER_UNIT % bitsize == 0 && MEM_ALIGN (op0) % GET_MODE_BITSIZE (fieldmode) == 0)))) { - if (GET_MODE (op0) != fieldmode) - { - if (MEM_P (op0)) - op0 = adjust_address (op0, fieldmode, offset); - else - op0 = simplify_gen_subreg (fieldmode, op0, GET_MODE (op0), - byte_offset); - } + /* APPLE LOCAL begin 4338167 mainline */ + if (MEM_P (op0)) + op0 = adjust_address (op0, fieldmode, offset); + else if (GET_MODE (op0) != fieldmode) + op0 = simplify_gen_subreg (fieldmode, op0, GET_MODE (op0), + byte_offset); + /* APPLE LOCAL end 4338167 mainline */ emit_move_insn (op0, value); return value; } @@ -1427,6 +1426,13 @@ extract_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, xbitpos = bitnum % unit; xop0 = adjust_address (xop0, bestmode, xoffset); + /* APPLE LOCAL begin 4338167 mainline */ + /* Make sure register is big enough for the whole field. */ + if (xoffset * BITS_PER_UNIT + unit + < offset * BITS_PER_UNIT + bitsize) + goto extzv_loses; + /* APPLE LOCAL end 4338167 mainline */ + /* Fetch it to a register in that size. */ xop0 = force_reg (bestmode, xop0); @@ -1556,6 +1562,13 @@ extract_bit_field (rtx str_rtx, unsigned HOST_WIDE_INT bitsize, xbitpos = bitnum % unit; xop0 = adjust_address (xop0, bestmode, xoffset); + /* APPLE LOCAL begin 4338167 mainline */ + /* Make sure register is big enough for the whole field. */ + if (xoffset * BITS_PER_UNIT + unit + < offset * BITS_PER_UNIT + bitsize) + goto extv_loses; + /* APPLE LOCAL end 4338167 mainline */ + /* Fetch it to a register in that size. */ xop0 = force_reg (bestmode, xop0); diff --git a/gcc/testsuite/ChangeLog.apple-ppc b/gcc/testsuite/ChangeLog.apple-ppc index d4e41707821..7a4f873c9b9 100644 --- a/gcc/testsuite/ChangeLog.apple-ppc +++ b/gcc/testsuite/ChangeLog.apple-ppc @@ -1,3 +1,7 @@ +2005-11-15 Dale Johannesen <dalej@apple.com> + + * gcc.c-torture/execute/20051113-1.c: New. + 2005-11-07 Dale Johannesen <dalej@apple.com> gcc.dg/darwin64-abi.c: Fix to test for diff --git a/gcc/testsuite/gcc.c-torture/execute/20051113-1.c b/gcc/testsuite/gcc.c-torture/execute/20051113-1.c new file mode 100644 index 00000000000..54f3df22f2c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20051113-1.c @@ -0,0 +1,72 @@ +/* APPLE LOCAL file 4338167 mainline */ +extern void *malloc(__SIZE_TYPE__); +extern void *memset(void *, int, __SIZE_TYPE__); +typedef struct +{ + short a; + unsigned short b; + unsigned short c; + unsigned long long Count; + long long Count2; +} __attribute__((packed)) Struct1; + +typedef struct +{ + short a; + unsigned short b; + unsigned short c; + unsigned long long d; + long long e; + long long f; +} __attribute__((packed)) Struct2; + +typedef union +{ + Struct1 a; + Struct2 b; +} Union; + +typedef struct +{ + int Count; + Union List[0]; +} __attribute__((packed)) Struct3; + +unsigned long long Sum (Struct3 *instrs) __attribute__((noinline)); +unsigned long long Sum (Struct3 *instrs) +{ + unsigned long long count = 0; + int i; + + for (i = 0; i < instrs->Count; i++) { + count += instrs->List[i].a.Count; + } + return count; +} +long long Sum2 (Struct3 *instrs) __attribute__((noinline)); +long long Sum2 (Struct3 *instrs) +{ + long long count = 0; + int i; + + for (i = 0; i < instrs->Count; i++) { + count += instrs->List[i].a.Count2; + } + return count; +} +main() { + Struct3 *p = malloc (sizeof (int) + 3 * sizeof(Struct1)); + memset(p, 0, sizeof(int) + 3*sizeof(Struct1)); + p->Count = 3; + p->List[0].a.Count = 555; + p->List[1].a.Count = 999; + p->List[2].a.Count = 0x101010101ULL; + p->List[0].a.Count2 = 555; + p->List[1].a.Count2 = 999; + p->List[2].a.Count2 = 0x101010101LL; + if (Sum(p) != 555 + 999 + 0x101010101ULL) + abort(); + if (Sum2(p) != 555 + 999 + 0x101010101LL) + abort(); + return 0; +} |