This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH, pretty-ipa] Use useless_type_conversion_p() instead of types_compatible_p()
- From: Martin Jambor <mjambor at suse dot cz>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 2 Apr 2009 11:46:48 +0200
- Subject: [PATCH, pretty-ipa] Use useless_type_conversion_p() instead of types_compatible_p()
Hi,
SRAs in pretty-ipa branch use unnecessarily strict predicate for type
compatibility, checking that the types need no conversion both ways
when actually only one direction is necessary. The patch below fixes
this by replacing all uses of types_compatible_p() by calls to
useless_type_conversion_p(), sometimes swapping the arguments as
necessary.
Bootstrapped and tested on x86_64-linux, I am about to commit it
shortly.
Thanks,
Martin
2009-04-02 Martin Jambor <mjambor@suse.cz>
* ipa-sra.c (sra_ipa_modify_expr): Use useless_type_conversion_p
instead of types_compatible_p.
(build_access_expr_1): Use useless_type_conversion_p instead of
types_compatible_p.
(sra_intra_modify_expr): Use useless_type_conversion_p instead of
types_compatible_p.
(load_assign_lhs_subreplacements): Use useless_type_conversion_p
instead of types_compatible_p.
(sra_intra_modify_assign): Use useless_type_conversion_p instead of
types_compatible_p.
Index: isra/gcc/ipa-sra.c
===================================================================
--- isra.orig/gcc/ipa-sra.c
+++ isra/gcc/ipa-sra.c
@@ -2338,7 +2338,7 @@ sra_ipa_modify_expr (tree *expr, gimple_
fprintf (dump_file, "\n");
}
- if (!types_compatible_p (cand->type, TREE_TYPE (*expr)))
+ if (!useless_type_conversion_p (TREE_TYPE (*expr), cand->type))
{
tree vce = build1 (VIEW_CONVERT_EXPR, TREE_TYPE (*expr), src);
*expr = vce;
@@ -2381,7 +2381,8 @@ build_access_expr_1 (tree *res, tree typ
tree tr_size, index;
HOST_WIDE_INT el_size;
- if (offset == 0 && exp_type && types_compatible_p (type, exp_type))
+ if (offset == 0 && exp_type
+ && useless_type_conversion_p (exp_type, type))
return true;
switch (TREE_CODE (type))
@@ -3437,7 +3438,7 @@ sra_intra_modify_expr (tree *expr, gimpl
gimple *stmt = gsi_stmt_ptr (gsi);
push_stmt_changes (stmt);
- if (!types_compatible_p (type, access->type))
+ if (!useless_type_conversion_p (type, access->type))
sra_fix_incompatible_types_for_expr (expr, type, access, gsi, write);
else
*expr = get_access_replacement (access);
@@ -3507,7 +3508,7 @@ load_assign_lhs_subreplacements (struct
{
gimple stmt;
- if (types_compatible_p (lacc->type, racc->type))
+ if (useless_type_conversion_p (lacc->type, racc->type))
stmt = gimple_build_assign (get_access_replacement (lacc),
get_access_replacement (racc));
else
@@ -3783,7 +3784,7 @@ sra_intra_modify_assign (gimple *stmt, g
{
pop_stmt_changes (stmt);
- if (!types_compatible_p (ltype, rtype))
+ if (!useless_type_conversion_p (ltype, rtype))
fix_modified_assign_compatibility (gsi, stmt, lacc, racc,
lhs, &rhs, ltype, rtype);
}