Commit 90bc1cb8 by Richard Guenther Committed by Richard Biener

re PR middle-end/45393 (ICE in redirect_eh_edge_1, at tree-eh.c:2135)

2010-08-25  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/45393
	* tree-ssa-math-opts.c (execute_cse_sincos_1): Properly transfer
	and clean EH info.  Avoid SSA update.
	(execute_cse_sincos): Cleanup the CFG if it has changed.

	* g++.dg/torture/pr45393.C: New testcase.

From-SVN: r163541
parent 9407f6bc
2010-08-25 Richard Guenther <rguenther@suse.de> 2010-08-25 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45393
* tree-ssa-math-opts.c (execute_cse_sincos_1): Properly transfer
and clean EH info. Avoid SSA update.
(execute_cse_sincos): Cleanup the CFG if it has changed.
2010-08-25 Richard Guenther <rguenther@suse.de>
PR middle-end/45379 PR middle-end/45379
* emit-rtl.c (set_mem_attributes_minus_bitpos): Handle * emit-rtl.c (set_mem_attributes_minus_bitpos): Handle
TARGET_MEM_REF in alignment computation. TARGET_MEM_REF in alignment computation.
......
2010-08-25 Richard Guenther <rguenther@suse.de>
PR tree-optimization/45393
* g++.dg/torture/pr45393.C: New testcase.
2010-08-25 Jakub Jelinek <jakub@redhat.com> 2010-08-25 Jakub Jelinek <jakub@redhat.com>
PR tree-optimization/45059 PR tree-optimization/45059
......
// { dg-do compile }
class FloatPoint;
class Path {
public:
~Path();
void moveTo(const FloatPoint&);
static void createEllipse(const FloatPoint& center, float rx, float ry);
};
extern "C" {
extern float cosf (float);
extern float sinf (float);
}
const float piFloat = static_cast<float>(3.14159265358979323846);
class FloatPoint {
public:
FloatPoint(float x, float y) : m_x(x), m_y(y) { }
float x() const;
float y() const;
float m_x, m_y;
};
void Path::createEllipse(const FloatPoint& center, float rx, float ry)
{
float cx = center.x();
float cy = center.y();
Path path;
float x = cx;
float y = cy;
unsigned step = 0, num = 100;
while (1) {
float angle = static_cast<float>(step) / num * 2.0f * piFloat;
x = cx + cosf(angle) * rx;
y = cy + sinf(angle) * ry;
step++;
if (step == 1)
path.moveTo(FloatPoint(x, y));
}
}
...@@ -641,7 +641,7 @@ maybe_record_sincos (VEC(gimple, heap) **stmts, ...@@ -641,7 +641,7 @@ maybe_record_sincos (VEC(gimple, heap) **stmts,
result of the cexpi call we insert before the use statement that result of the cexpi call we insert before the use statement that
dominates all other candidates. */ dominates all other candidates. */
static void static bool
execute_cse_sincos_1 (tree name) execute_cse_sincos_1 (tree name)
{ {
gimple_stmt_iterator gsi; gimple_stmt_iterator gsi;
...@@ -652,6 +652,7 @@ execute_cse_sincos_1 (tree name) ...@@ -652,6 +652,7 @@ execute_cse_sincos_1 (tree name)
VEC(gimple, heap) *stmts = NULL; VEC(gimple, heap) *stmts = NULL;
basic_block top_bb = NULL; basic_block top_bb = NULL;
int i; int i;
bool cfg_changed = false;
type = TREE_TYPE (name); type = TREE_TYPE (name);
FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, name) FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, name)
...@@ -683,16 +684,17 @@ execute_cse_sincos_1 (tree name) ...@@ -683,16 +684,17 @@ execute_cse_sincos_1 (tree name)
if (seen_cos + seen_sin + seen_cexpi <= 1) if (seen_cos + seen_sin + seen_cexpi <= 1)
{ {
VEC_free(gimple, heap, stmts); VEC_free(gimple, heap, stmts);
return; return false;
} }
/* Simply insert cexpi at the beginning of top_bb but not earlier than /* Simply insert cexpi at the beginning of top_bb but not earlier than
the name def statement. */ the name def statement. */
fndecl = mathfn_built_in (type, BUILT_IN_CEXPI); fndecl = mathfn_built_in (type, BUILT_IN_CEXPI);
if (!fndecl) if (!fndecl)
return; return false;
res = make_rename_temp (TREE_TYPE (TREE_TYPE (fndecl)), "sincostmp"); res = create_tmp_reg (TREE_TYPE (TREE_TYPE (fndecl)), "sincostmp");
stmt = gimple_build_call (fndecl, 1, name); stmt = gimple_build_call (fndecl, 1, name);
res = make_ssa_name (res, stmt);
gimple_call_set_lhs (stmt, res); gimple_call_set_lhs (stmt, res);
def_stmt = SSA_NAME_DEF_STMT (name); def_stmt = SSA_NAME_DEF_STMT (name);
...@@ -738,11 +740,14 @@ execute_cse_sincos_1 (tree name) ...@@ -738,11 +740,14 @@ execute_cse_sincos_1 (tree name)
stmt = gimple_build_assign (gimple_call_lhs (use_stmt), rhs); stmt = gimple_build_assign (gimple_call_lhs (use_stmt), rhs);
gsi = gsi_for_stmt (use_stmt); gsi = gsi_for_stmt (use_stmt);
gsi_insert_after (&gsi, stmt, GSI_SAME_STMT); gsi_replace (&gsi, stmt, true);
gsi_remove (&gsi, true); if (gimple_purge_dead_eh_edges (gimple_bb (stmt)))
cfg_changed = true;
} }
VEC_free(gimple, heap, stmts); VEC_free(gimple, heap, stmts);
return cfg_changed;
} }
/* Go through all calls to sin, cos and cexpi and call execute_cse_sincos_1 /* Go through all calls to sin, cos and cexpi and call execute_cse_sincos_1
...@@ -752,6 +757,7 @@ static unsigned int ...@@ -752,6 +757,7 @@ static unsigned int
execute_cse_sincos (void) execute_cse_sincos (void)
{ {
basic_block bb; basic_block bb;
bool cfg_changed = false;
calculate_dominance_info (CDI_DOMINATORS); calculate_dominance_info (CDI_DOMINATORS);
...@@ -778,7 +784,7 @@ execute_cse_sincos (void) ...@@ -778,7 +784,7 @@ execute_cse_sincos (void)
CASE_FLT_FN (BUILT_IN_CEXPI): CASE_FLT_FN (BUILT_IN_CEXPI):
arg = gimple_call_arg (stmt, 0); arg = gimple_call_arg (stmt, 0);
if (TREE_CODE (arg) == SSA_NAME) if (TREE_CODE (arg) == SSA_NAME)
execute_cse_sincos_1 (arg); cfg_changed |= execute_cse_sincos_1 (arg);
break; break;
default:; default:;
...@@ -788,7 +794,7 @@ execute_cse_sincos (void) ...@@ -788,7 +794,7 @@ execute_cse_sincos (void)
} }
free_dominance_info (CDI_DOMINATORS); free_dominance_info (CDI_DOMINATORS);
return 0; return cfg_changed ? TODO_cleanup_cfg : 0;
} }
static bool static bool
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment