gimple: Remove special handling of COND_EXPR for COMPARISON_CLASS_P [PR116949, PR114785]

After r13-707-g68e0063397ba82, COND_EXPR for gimple assign no longer could contain a comparison.
The vectorizer was builting gimple assigns with comparison until r15-4695-gd17e672ce82e69
(which added an assert to make sure it no longer builds it).

So let's remove the special handling COND_EXPR in a few places and add an assert to
gimple_build_assign_1 to make sure we don't build a gimple assign any more with a comparison.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	PR middle-end/114785
	PR middle-end/116949
	* gimple-match-exports.cc (maybe_push_res_to_seq): Remove special
	handling of COMPARISON_CLASS_P in COND_EXPR/VEC_COND_EXPR.
	(gimple_extract): Likewise.
	* gimple-walk.cc (walk_stmt_load_store_addr_ops): Likewise.
	* gimple.cc (gimple_build_assign_1): Add assert for COND_EXPR
	so its 1st operand is not a comparison.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
This commit is contained in:
Andrew Pinski 2024-10-29 14:43:42 -07:00
parent 717051a690
commit b60031e8f9
3 changed files with 4 additions and 22 deletions

View File

@ -489,12 +489,6 @@ maybe_push_res_to_seq (gimple_match_op *res_op, gimple_seq *seq, tree res)
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (ops[i]))
return NULL_TREE;
if (num_ops > 0 && COMPARISON_CLASS_P (ops[0]))
for (unsigned int i = 0; i < 2; ++i)
if (TREE_CODE (TREE_OPERAND (ops[0], i)) == SSA_NAME
&& SSA_NAME_OCCURS_IN_ABNORMAL_PHI (TREE_OPERAND (ops[0], i)))
return NULL_TREE;
if (res_op->code.is_tree_code ())
{
auto code = tree_code (res_op->code);
@ -786,11 +780,7 @@ gimple_extract (gimple *stmt, gimple_match_op *res_op,
}
case GIMPLE_TERNARY_RHS:
{
tree rhs1 = gimple_assign_rhs1 (stmt);
if (code == COND_EXPR && COMPARISON_CLASS_P (rhs1))
rhs1 = valueize_condition (rhs1);
else
rhs1 = valueize_op (rhs1);
tree rhs1 = valueize_op (gimple_assign_rhs1 (stmt));
tree rhs2 = valueize_op (gimple_assign_rhs2 (stmt));
tree rhs3 = valueize_op (gimple_assign_rhs3 (stmt));
res_op->set_op (code, type, rhs1, rhs2, rhs3);

View File

@ -835,17 +835,6 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data,
;
else if (TREE_CODE (op) == ADDR_EXPR)
ret |= visit_addr (stmt, TREE_OPERAND (op, 0), op, data);
/* COND_EXPR and VCOND_EXPR rhs1 argument is a comparison
tree with two operands. */
else if (i == 1 && COMPARISON_CLASS_P (op))
{
if (TREE_CODE (TREE_OPERAND (op, 0)) == ADDR_EXPR)
ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 0),
0), op, data);
if (TREE_CODE (TREE_OPERAND (op, 1)) == ADDR_EXPR)
ret |= visit_addr (stmt, TREE_OPERAND (TREE_OPERAND (op, 1),
0), op, data);
}
}
}
else if (gcall *call_stmt = dyn_cast <gcall *> (stmt))

View File

@ -475,6 +475,9 @@ gimple_build_assign_1 (tree lhs, enum tree_code subcode, tree op1,
gimple_build_with_ops_stat (GIMPLE_ASSIGN, (unsigned)subcode, num_ops
PASS_MEM_STAT));
gimple_assign_set_lhs (p, lhs);
/* For COND_EXPR, op1 should not be a comparison. */
if (op1 && subcode == COND_EXPR)
gcc_assert (!COMPARISON_CLASS_P (op1));
gimple_assign_set_rhs1 (p, op1);
if (op2)
{