aboutsummaryrefslogtreecommitdiff
path: root/gcc/genmatch.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-10-30 15:36:05 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-10-30 15:36:05 +0000
commitd822570f733f2660b8bd5c78cf5077e654c4387e (patch)
tree138ab18df255eae4e18cb747ac189b901263aeae /gcc/genmatch.c
parent665c06cec2b2b15addfe22e203c7d0e90f74424b (diff)
downloadgcc-d822570f733f2660b8bd5c78cf5077e654c4387e.zip
gcc-d822570f733f2660b8bd5c78cf5077e654c4387e.tar.gz
gcc-d822570f733f2660b8bd5c78cf5077e654c4387e.tar.bz2
genmatch.c (capture_info::walk_c_expr): Ignore capture uses inside TREE_TYPE ().
2014-10-30 Richard Biener <rguenther@suse.de> * genmatch.c (capture_info::walk_c_expr): Ignore capture uses inside TREE_TYPE (). * gimple-ssa-strength-reduction.c (stmt_cost): Use CASE_CONVERT. (find_candidates_dom_walker::before_dom_children): Likewise. (replace_mult_candidate): Use CONVERT_EXPR_CODE_P. (replace_profitable_candidates): Likewise. * tree-ssa-dom.c (initialize_hash_element): Canonicalize CONVERT_EXPR_CODE_P to CONVERT_EXPR. * convert.c (convert_to_integer): Use CASE_CONVERT. From-SVN: r216939
Diffstat (limited to 'gcc/genmatch.c')
-rw-r--r--gcc/genmatch.c41
1 files changed, 27 insertions, 14 deletions
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index ebdb7d3..35d852c 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -2004,21 +2004,34 @@ capture_info::walk_result (operand *o, bool conditional_p)
void
capture_info::walk_c_expr (c_expr *e)
{
- /* Give up for C exprs mentioning captures. */
+ /* Give up for C exprs mentioning captures not inside TREE_TYPE (). */
+ unsigned p_depth = 0;
for (unsigned i = 0; i < e->code.length (); ++i)
- if (e->code[i].type == CPP_ATSIGN
- && (e->code[i+1].type == CPP_NUMBER
- || e->code[i+1].type == CPP_NAME)
- && !(e->code[i+1].flags & PREV_WHITE))
- {
- const cpp_token *n = &e->code[i+1];
- const char *id;
- if (n->type == CPP_NUMBER)
- id = (const char *)n->val.str.text;
- else
- id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str;
- info[(*e->capture_ids)[id]].force_no_side_effects_p = true;
- }
+ {
+ const cpp_token *t = &e->code[i];
+ const cpp_token *n = i < e->code.length () - 1 ? &e->code[i+1] : NULL;
+ if (t->type == CPP_NAME
+ && strcmp ((const char *)CPP_HASHNODE
+ (t->val.node.node)->ident.str, "TREE_TYPE") == 0
+ && n->type == CPP_OPEN_PAREN)
+ p_depth++;
+ else if (t->type == CPP_CLOSE_PAREN
+ && p_depth > 0)
+ p_depth--;
+ else if (p_depth == 0
+ && t->type == CPP_ATSIGN
+ && (n->type == CPP_NUMBER
+ || n->type == CPP_NAME)
+ && !(n->flags & PREV_WHITE))
+ {
+ const char *id;
+ if (n->type == CPP_NUMBER)
+ id = (const char *)n->val.str.text;
+ else
+ id = (const char *)CPP_HASHNODE (n->val.node.node)->ident.str;
+ info[(*e->capture_ids)[id]].force_no_side_effects_p = true;
+ }
+ }
}