[Bug tree-optimization/33535] New: bitpos_of_field() returns false result base of hard coded multiplication by 8
tomerben at ceva-dsp dot com
gcc-bugzilla@gcc.gnu.org
Sun Sep 23 08:44:00 GMT 2007
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
More information about the Gcc-bugs
mailing list