From 201bc2b0bf9da2c5de0660e0f03fdc975350e29f Mon Sep 17 00:00:00 2001 From: ian Date: Wed, 12 Oct 2005 20:30:46 +0000 Subject: [PATCH] * combine.c (make_extraction): Correct offset computation. * gcc.c-torture/execute/20051012-1.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@105330 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 ++++ gcc/combine.c | 5 +++-- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.c-torture/execute/20051012-1.c | 24 ++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.c-torture/execute/20051012-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 93da6872046..f2b9db354b6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,7 @@ +2005-10-12 Adrian Straetling + + * combine.c (make_extraction): Correct offset computation. + 2005-10-12 Hans-Peter Nilsson * config/cris/t-linux (LIMITS_H_TEST): Define. diff --git a/gcc/combine.c b/gcc/combine.c index 3be34e4b44d..ff10663a147 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -6512,11 +6512,12 @@ make_extraction (enum machine_mode mode, rtx inner, HOST_WIDE_INT pos, offset -= GET_MODE_SIZE (is_mode) - GET_MODE_SIZE (inner_mode); /* If this is a constant position, we can move to the desired byte. - Be careful not to go beyond the original object. */ + Be careful not to go beyond the original object and maintain the + natural alignment of the memory. */ if (pos_rtx == 0) { enum machine_mode bfmode = smallest_mode_for_size (len, MODE_INT); - offset += pos / GET_MODE_BITSIZE (bfmode); + offset += (pos / GET_MODE_BITSIZE (bfmode)) * GET_MODE_SIZE (bfmode); pos %= GET_MODE_BITSIZE (bfmode); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 7abf169d217..be34d210880 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2005-10-12 Adrian Straetling + + * gcc.c-torture/execute/20051012-1.c: New test. + 2005-10-12 Paul Thomas PR fortran/18082 diff --git a/gcc/testsuite/gcc.c-torture/execute/20051012-1.c b/gcc/testsuite/gcc.c-torture/execute/20051012-1.c new file mode 100644 index 00000000000..f12f42913cc --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/20051012-1.c @@ -0,0 +1,24 @@ +extern void abort (void); + +struct type +{ + int *a; + + int b:16; + unsigned int p:9; +} t; + +unsigned int +foo () +{ + return t.p; +} + +int +main (void) +{ + t.p = 8; + if (foo (t) != 8) + abort (); + return 0; +} -- 2.11.0