This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/33535] New: bitpos_of_field() returns false result base of hard coded multiplication by 8
- From: "tomerben at ceva-dsp dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Sep 2007 08:44:01 -0000
- Subject: [Bug tree-optimization/33535] New: bitpos_of_field() returns false result base of hard coded multiplication by 8
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Taken from tree-ssa-structalias.c:
The original code:
static unsigned HOST_WIDE_INT
bitpos_of_field (const tree fdecl)
{
if (TREE_CODE (DECL_FIELD_OFFSET (fdecl)) != INTEGER_CST
|| TREE_CODE (DECL_FIELD_BIT_OFFSET (fdecl)) != INTEGER_CST)
return -1;
return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * 8)
+ tree_low_cst (DECL_FIELD_BIT_OFFSET (fdecl), 1);
}
I think the code needs to be:
static unsigned HOST_WIDE_INT
bitpos_of_field (const tree fdecl)
{
if (TREE_CODE (DECL_FIELD_OFFSET (fdecl)) != INTEGER_CST
|| TREE_CODE (DECL_FIELD_BIT_OFFSET (fdecl)) != INTEGER_CST)
return -1;
return (tree_low_cst (DECL_FIELD_OFFSET (fdecl), 1) * BITS_PER_UNIT)
+ tree_low_cst (DECL_FIELD_BIT_OFFSET (fdecl), 1);
}
The offset in bits need to consider the BITS_PER_UNIT macro instead of hard
coded 8. This is usefull for machines that have different value of
BITS_PER_UNIT (16 for e.g. on the port I'm working on).
--
Summary: bitpos_of_field() returns false result base of hard
coded multiplication by 8
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tomerben at ceva-dsp dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33535