For the ptx port, I've needed to write a new pass which ensures all
objects go into address spaces as required by the machine. This uses the
regimplification code in gimplify-me.c, and that requires some fixes and
upgrades.
Here's the first. When address spaces change, an ADDR_EXPR may have to
be changed to ADDR_SPACE_CONVERT_EXPR, and these two have different
representations in gimple. This patch stops the regimplification code
from creating invalid gimple in such a case.
Bootstrapped and tested on x86_64-linux, ok?
Bernd
commit 00edd2d382d406b2f729885f08aa16928552d9d0
Author: Bernd Schmidt <ber...@codesourcery.com>
Date: Wed Jun 11 18:41:09 2014 +0200
Fix an issue with regimplification.
This is in preparation for the lower-address-spaces pass for the ptx port. We
need to teach the regimplifier how to handle the case when an ADDR_EXPR turns
into something else, like an ADDR_SPACE_CONVERT_EXPR.
gcc/
* gimplify-me.c (gimple_regimplify_operands): Handle case where a
GIMPLE_SINGLE_RHS is turned into something else.
diff --git a/gcc/gimplify-me.c b/gcc/gimplify-me.c
index 05e986a..467ec6c 100644
--- a/gcc/gimplify-me.c
+++ b/gcc/gimplify-me.c
@@ -248,6 +248,22 @@ gimple_regimplify_operands (gimple stmt, gimple_stmt_iterator *gsi_p)
gimplify_expr (&op, &pre, NULL, is_gimple_val, fb_rvalue);
gimple_set_op (stmt, i - 1, op);
}
+ if (is_gimple_assign (stmt)
+ && num_ops == 2
+ && (get_gimple_rhs_class (gimple_expr_code (stmt))
+ == GIMPLE_SINGLE_RHS)
+ && (get_gimple_rhs_class (TREE_CODE (gimple_op (stmt, 1)))
+ != GIMPLE_SINGLE_RHS))
+ {
+ tree rhs = gimple_assign_rhs1 (stmt);
+ tree temp = create_tmp_reg (TREE_TYPE (rhs), NULL);
+ if (gimple_in_ssa_p (cfun))
+ temp = make_ssa_name (temp, NULL);
+ gimple_assign_set_rhs1 (stmt, temp);
+ gimple_assign_set_rhs_code (stmt, TREE_CODE (temp));
+ gimple pre_stmt = gimple_build_assign (temp, rhs);
+ gimple_seq_add_stmt_without_update (&pre, pre_stmt);
+ }
lhs = gimple_get_lhs (stmt);
/* If the LHS changed it in a way that requires a simple RHS,