aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-reassoc.c
diff options
context:
space:
mode:
authorLi Jia He <helijia@linux.ibm.com>2019-09-16 14:21:20 +0000
committerMartin Liska <marxin@gcc.gnu.org>2019-09-16 14:21:20 +0000
commit5f487a349de62613d7fa429bcbfbeeafbfc94f3a (patch)
treed63d3e1bb2210eb3e25095d2dc0deab2b5ccf72a /gcc/tree-ssa-reassoc.c
parent10f30ac9cda947d117e50f0cbd4cf94ee70a944f (diff)
downloadgcc-5f487a349de62613d7fa429bcbfbeeafbfc94f3a.zip
gcc-5f487a349de62613d7fa429bcbfbeeafbfc94f3a.tar.gz
gcc-5f487a349de62613d7fa429bcbfbeeafbfc94f3a.tar.bz2
Auto-generate maybe_fold_and/or_comparisons from match.pd
2019-09-16 Li Jia He <helijia@linux.ibm.com> Martin Liska <mliska@suse.cz> * gimple-fold.c (and_comparisons_1): Add type as first argument. (and_var_with_comparison): Likewise. (and_var_with_comparison_1): Likewise. (or_comparisons_1): Likewise. (or_var_with_comparison): Likewise. (or_var_with_comparison_1): Likewise. (maybe_fold_and_comparisons): Call maybe_fold_comparisons_from_match_pd. (maybe_fold_or_comparisons): Likewise. (maybe_fold_comparisons_from_match_pd): New. * gimple-fold.h (maybe_fold_and_comparisons): Add type argument. (maybe_fold_or_comparisons): Likewise. * gimple.c (gimple_size): Make it public and add num_ops argument. (gimple_init): New function. (gimple_alloc): Call gimple_init. * gimple.h (gimple_size): New. (gimple_init): Likewise. * tree-if-conv.c (fold_or_predicates): Pass type. * tree-ssa-ifcombine.c (ifcombine_ifandif): Likewise. * tree-ssa-reassoc.c (eliminate_redundant_comparison): Likewise. (optimize_vec_cond_expr): Likewise. (ovce_extract_ops): Return type of conditional expression. * tree-ssanames.c (init_ssa_name_imm_use): New. (make_ssa_name_fn): Use init_ssa_name_imm_use. * tree-ssanames.h (init_ssa_name_imm_use): New. Co-Authored-By: Martin Liska <mliska@suse.cz> From-SVN: r275748
Diffstat (limited to 'gcc/tree-ssa-reassoc.c')
-rw-r--r--gcc/tree-ssa-reassoc.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c
index df76e66..510dfd1 100644
--- a/gcc/tree-ssa-reassoc.c
+++ b/gcc/tree-ssa-reassoc.c
@@ -2088,12 +2088,15 @@ eliminate_redundant_comparison (enum tree_code opcode,
/* If we got here, we have a match. See if we can combine the
two comparisons. */
+ tree type = TREE_TYPE (gimple_assign_lhs (def1));
if (opcode == BIT_IOR_EXPR)
- t = maybe_fold_or_comparisons (lcode, op1, op2,
+ t = maybe_fold_or_comparisons (type,
+ lcode, op1, op2,
rcode, gimple_assign_rhs1 (def2),
gimple_assign_rhs2 (def2));
else
- t = maybe_fold_and_comparisons (lcode, op1, op2,
+ t = maybe_fold_and_comparisons (type,
+ lcode, op1, op2,
rcode, gimple_assign_rhs1 (def2),
gimple_assign_rhs2 (def2));
if (!t)
@@ -3745,10 +3748,11 @@ optimize_range_tests (enum tree_code opcode,
/* A subroutine of optimize_vec_cond_expr to extract and canonicalize
the operands of the VEC_COND_EXPR. Returns ERROR_MARK on failure,
- otherwise the comparison code. */
+ otherwise the comparison code. TYPE is a return value that is set
+ to type of comparison. */
static tree_code
-ovce_extract_ops (tree var, gassign **rets, bool *reti)
+ovce_extract_ops (tree var, gassign **rets, bool *reti, tree *type)
{
if (TREE_CODE (var) != SSA_NAME)
return ERROR_MARK;
@@ -3790,6 +3794,8 @@ ovce_extract_ops (tree var, gassign **rets, bool *reti)
*rets = stmt;
if (reti)
*reti = inv;
+ if (type)
+ *type = TREE_TYPE (cond);
return cmp;
}
@@ -3811,7 +3817,8 @@ optimize_vec_cond_expr (tree_code opcode, vec<operand_entry *> *ops)
gassign *stmt0;
bool invert;
- tree_code cmp0 = ovce_extract_ops (elt0, &stmt0, &invert);
+ tree type;
+ tree_code cmp0 = ovce_extract_ops (elt0, &stmt0, &invert, &type);
if (cmp0 == ERROR_MARK)
continue;
@@ -3820,7 +3827,7 @@ optimize_vec_cond_expr (tree_code opcode, vec<operand_entry *> *ops)
tree &elt1 = (*ops)[j]->op;
gassign *stmt1;
- tree_code cmp1 = ovce_extract_ops (elt1, &stmt1, NULL);
+ tree_code cmp1 = ovce_extract_ops (elt1, &stmt1, NULL, NULL);
if (cmp1 == ERROR_MARK)
continue;
@@ -3834,9 +3841,11 @@ optimize_vec_cond_expr (tree_code opcode, vec<operand_entry *> *ops)
tree comb;
if (opcode == BIT_AND_EXPR)
- comb = maybe_fold_and_comparisons (cmp0, x0, y0, cmp1, x1, y1);
+ comb = maybe_fold_and_comparisons (type, cmp0, x0, y0, cmp1, x1,
+ y1);
else if (opcode == BIT_IOR_EXPR)
- comb = maybe_fold_or_comparisons (cmp0, x0, y0, cmp1, x1, y1);
+ comb = maybe_fold_or_comparisons (type, cmp0, x0, y0, cmp1, x1,
+ y1);
else
gcc_unreachable ();
if (comb == NULL)