This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[patch] combine.c: Fix a subreg bit position computation.
- From: Kazu Hirata <kazu at hxi dot com>
- To: gcc-patches at gcc dot gnu dot org
- Subject: [patch] combine.c: Fix a subreg bit position computation.
Hi,
Attached is a patch to fix a subreg bit position computation in
expand_field_assignemnt() in combine.c.
A recent patch caused execute/930208-1.c to fail on h8300 port with
-mno-h option due to the bug addressed in this message.
During compilation of 930208-1.c, expand_field_assignment() in
combine.c transforms
(set (strict_low_part (subreg:QI (reg:SI 17) 1))
(const_int 2))
into
(set (reg/v:SI 17)
(ior:SI (and:SI (reg:SI 17)
(const_int 0xffffff00))
(const_int 0x2)))
However, since h8300 port has both WORDS_BIG_ENDIAN and
BYTES_BIG_ENDIAN equal to 1, the correct transformation would be
(set (reg:SI 17)
(ior:SI (and:SI (reg:SI 17)
(const_int 0xff00ffff))
(const_int 0x20000)))
The patch fixes this problem by replacing the ad hoc subreg bit
position computation with subreg_lsb().
Regtesting in progress on h8300 port. OK to apply if no regression is
found?
Kazu Hirata
2002-01-10 Kazu Hirata <kazu@hxi.com>
* combine.c (expand_field_assignment): Use subreg_lsb().
Index: combine.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/combine.c,v
retrieving revision 1.254
diff -u -p -r1.254 combine.c
--- combine.c 2002/01/10 07:37:51 1.254
+++ combine.c 2002/01/10 09:37:22
@@ -5685,11 +5685,9 @@ expand_field_assignment (x)
if (GET_CODE (SET_DEST (x)) == STRICT_LOW_PART
&& GET_CODE (XEXP (SET_DEST (x), 0)) == SUBREG)
{
- int byte_offset = SUBREG_BYTE (XEXP (SET_DEST (x), 0));
-
inner = SUBREG_REG (XEXP (SET_DEST (x), 0));
len = GET_MODE_BITSIZE (GET_MODE (XEXP (SET_DEST (x), 0)));
- pos = GEN_INT (BITS_PER_WORD * (byte_offset / UNITS_PER_WORD));
+ pos = GEN_INT (subreg_lsb (XEXP (SET_DEST (x), 0)));
}
else if (GET_CODE (SET_DEST (x)) == ZERO_EXTRACT
&& GET_CODE (XEXP (SET_DEST (x), 1)) == CONST_INT)