* tree.h (maybe_fold_offset_to_component_ref): Declare.
* tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Export.
* fold-const.c (fold_unary): Use it.
* gcc.dg/tree-ssa/foldaddr-2.c: New file.
From-SVN: r123664
+2007-04-08 Jan Hubicka <jh@suse.cz>
+
+ * tree.h (maybe_fold_offset_to_component_ref): Declare.
+ * tree-ssa-ccp.c (maybe_fold_offset_to_component_ref): Export.
+ * fold-const.c (fold_unary): Use it.
+
2007-04-08 Andrew Pinski <andrew_pinski@playstation.sony.com>
* varasm.c (assemble_variable): Remove call to
return fold_convert (type, build_fold_addr_expr (base));
}
+ /* Convert (type *)&A into &A->field_of_type_and_offset_0. */
+ if (TREE_CODE (op0) == ADDR_EXPR && POINTER_TYPE_P (type)
+ && (tem = maybe_fold_offset_to_component_ref
+ (TREE_TYPE (TREE_OPERAND (op0, 0)), TREE_OPERAND (op0, 0),
+ integer_zero_node, TREE_TYPE (type), false)))
+ return build_fold_addr_expr_with_type (tem, type);
+
if ((TREE_CODE (op0) == MODIFY_EXPR
|| TREE_CODE (op0) == GIMPLE_MODIFY_STMT)
&& TREE_CONSTANT (GENERIC_TREE_OPERAND (op0, 1))
+2007-04-08 Jan Hubicka <jh@suse.cz>
+
+ * gcc.dg/tree-ssa/foldaddr-2.c: New file.
+
2007-04-07 Paul Thomas <pault@gcc.gnu.org>
PR fortran/31257
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O1 -fdump-tree-optimized" } */
+struct a{
+ int a;
+ int b;
+} a;
+int *
+t()
+{
+ return (int *)&a;
+}
+/* { dg-final { scan-tree-dump "a.a" "optimized"} } */
+/* { dg-final { cleanup-tree-dump "optimized" } } */
is the desired result type. */
/* ??? This doesn't handle class inheritance. */
-static tree
+tree
maybe_fold_offset_to_component_ref (tree record_type, tree base, tree offset,
tree orig_type, bool base_is_ptr)
{
extern void fold_undefer_overflow_warnings (bool, tree, int);
extern void fold_undefer_and_ignore_overflow_warnings (void);
extern bool fold_deferring_overflow_warnings_p (void);
+extern tree maybe_fold_offset_to_component_ref (tree, tree, tree,
+ tree, bool);
extern tree force_fit_type_double (tree, unsigned HOST_WIDE_INT, HOST_WIDE_INT,
int, bool);