*/
if (TREE_CODE (addr) == ADDR_EXPR
&& TREE_CODE (TREE_TYPE (addrtype)) == VECTOR_TYPE
&& useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype)))
&& host_integerp (off, 1))
{
unsigned HOST_WIDE_INT offset = tree_low_cst (off, 1);
tree part_width = TYPE_SIZE (type);
unsigned HOST_WIDE_INT part_widthi
= tree_low_cst (part_width, 0) / BITS_PER_UNIT;
unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT;
tree index = bitsize_int (indexi);
if (offset / part_widthi
<= TYPE_VECTOR_SUBPARTS (TREE_TYPE (addrtype)))
return fold_build3 (BIT_FIELD_REF, type, TREE_OPERAND (addr, 0),
part_width, index);
}
/* ((foo*)&complexfoo)[1] -> __imag__ complexfoo */
if (TREE_CODE (addr) == ADDR_EXPR
&& TREE_CODE (TREE_TYPE (addrtype)) == COMPLEX_TYPE
&& useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (addrtype))))
{
tree size = TYPE_SIZE_UNIT (type);
if (tree_int_cst_equal (size, off))
return fold_build1 (IMAGPART_EXPR, type, TREE_OPERAND (addr, 0));
}
/* *(p + CST) -> MEM_REF . */
if (TREE_CODE (addr) != ADDR_EXPR
|| DECL_P (TREE_OPERAND (addr, 0)))
return fold_build2 (MEM_REF, type,
addr,
build_int_cst_wide (ptype,
TREE_INT_CST_LOW (off),
TREE_INT_CST_HIGH (off)));
}
/* *(foo *)fooarrptr => (*fooarrptr)[0] */
if (TREE_CODE (TREE_TYPE (subtype)) == ARRAY_TYPE
&& TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (subtype)))) == INTEGER_CST
&& useless_type_conversion_p (type, TREE_TYPE (TREE_TYPE (subtype))))
{
tree type_domain;
tree min_val = size_zero_node;
tree osub = sub;
sub = gimple_fold_indirect_ref (sub);
if (! sub)
sub = build1 (INDIRECT_REF, TREE_TYPE (subtype), osub);
type_domain = TYPE_DOMAIN (TREE_TYPE (sub));
if (type_domain && TYPE_MIN_VALUE (type_domain))
min_val = TYPE_MIN_VALUE (type_domain);
if (TREE_CODE (min_val) == INTEGER_CST)
return build4 (ARRAY_REF, type, sub, min_val, NULL_TREE, NULL_TREE);
}
return NULL_TREE;
}