From 95f27849a580ac834d4f51a0642da9671f0a9dee Mon Sep 17 00:00:00 2001 From: Richard Biener Date: Mon, 19 Oct 2020 11:07:36 +0200 Subject: [PATCH] tree-optimization/97466 - remove spurious assert This removes an assertion that was supposed to be only for temporary debugging. I've also re-indented the code which I missed as well. 2020-10-19 Richard Biener PR tree-optimization/97466 * tree-vect-slp.c (vect_get_and_check_slp_defs): Remove spurious assert, re-indent. --- gcc/tree-vect-slp.c | 128 +++++++++++++++++++++----------------------- 1 file changed, 62 insertions(+), 66 deletions(-) diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c index c3e6d67067c..a2fbbc56bcc 100644 --- a/gcc/tree-vect-slp.c +++ b/gcc/tree-vect-slp.c @@ -531,78 +531,74 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap, oprnd = oprnd_info->ops[stmt_num]; tree type = TREE_TYPE (oprnd); - if (!types_compatible_p (oprnd_info->first_op_type, type)) + if (!types_compatible_p (oprnd_info->first_op_type, type)) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Build SLP failed: different operand types\n"); + return 1; + } + + /* Not first stmt of the group, check that the def-stmt/s match + the def-stmt/s of the first stmt. Allow different definition + types for reduction chains: the first stmt must be a + vect_reduction_def (a phi node), and the rest + end in the reduction chain. */ + if ((!vect_def_types_match (oprnd_info->first_dt, dt) + && !(oprnd_info->first_dt == vect_reduction_def + && !STMT_VINFO_DATA_REF (stmt_info) + && REDUC_GROUP_FIRST_ELEMENT (stmt_info) + && def_stmt_info + && !STMT_VINFO_DATA_REF (def_stmt_info) + && (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info) + == REDUC_GROUP_FIRST_ELEMENT (stmt_info)))) + || (!STMT_VINFO_DATA_REF (stmt_info) + && REDUC_GROUP_FIRST_ELEMENT (stmt_info) + && ((!def_stmt_info + || STMT_VINFO_DATA_REF (def_stmt_info) + || (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info) + != REDUC_GROUP_FIRST_ELEMENT (stmt_info))) + != (oprnd_info->first_dt != vect_reduction_def)))) + { + /* Try swapping operands if we got a mismatch. For BB + vectorization only in case it will clearly improve things. */ + if (i == commutative_op && !swapped + && (!is_a (vinfo) + || (!vect_def_types_match ((*oprnds_info)[i+1]->first_dt, + dts[i+1]) + && (vect_def_types_match (oprnd_info->first_dt, dts[i+1]) + || vect_def_types_match + ((*oprnds_info)[i+1]->first_dt, dts[i]))))) { - gcc_assert ((i != commutative_op - && (commutative_op == -1U - || i != commutative_op + 1))); if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Build SLP failed: different operand types\n"); - return 1; + dump_printf_loc (MSG_NOTE, vect_location, + "trying swapped operands\n"); + std::swap (dts[i], dts[i+1]); + std::swap ((*oprnds_info)[i]->def_stmts[stmt_num], + (*oprnds_info)[i+1]->def_stmts[stmt_num]); + std::swap ((*oprnds_info)[i]->ops[stmt_num], + (*oprnds_info)[i+1]->ops[stmt_num]); + swapped = true; + continue; } - /* Not first stmt of the group, check that the def-stmt/s match - the def-stmt/s of the first stmt. Allow different definition - types for reduction chains: the first stmt must be a - vect_reduction_def (a phi node), and the rest - end in the reduction chain. */ - if ((!vect_def_types_match (oprnd_info->first_dt, dt) - && !(oprnd_info->first_dt == vect_reduction_def - && !STMT_VINFO_DATA_REF (stmt_info) - && REDUC_GROUP_FIRST_ELEMENT (stmt_info) - && def_stmt_info - && !STMT_VINFO_DATA_REF (def_stmt_info) - && (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info) - == REDUC_GROUP_FIRST_ELEMENT (stmt_info)))) - || (!STMT_VINFO_DATA_REF (stmt_info) - && REDUC_GROUP_FIRST_ELEMENT (stmt_info) - && ((!def_stmt_info - || STMT_VINFO_DATA_REF (def_stmt_info) - || (REDUC_GROUP_FIRST_ELEMENT (def_stmt_info) - != REDUC_GROUP_FIRST_ELEMENT (stmt_info))) - != (oprnd_info->first_dt != vect_reduction_def)))) + if (is_a (vinfo)) { - /* Try swapping operands if we got a mismatch. For BB - vectorization only in case it will clearly improve things. */ - if (i == commutative_op && !swapped - && (!is_a (vinfo) - || (!vect_def_types_match ((*oprnds_info)[i+1]->first_dt, - dts[i+1]) - && (vect_def_types_match (oprnd_info->first_dt, - dts[i+1]) - || vect_def_types_match - ((*oprnds_info)[i+1]->first_dt, dts[i]))))) - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_NOTE, vect_location, - "trying swapped operands\n"); - std::swap (dts[i], dts[i+1]); - std::swap ((*oprnds_info)[i]->def_stmts[stmt_num], - (*oprnds_info)[i+1]->def_stmts[stmt_num]); - std::swap ((*oprnds_info)[i]->ops[stmt_num], - (*oprnds_info)[i+1]->ops[stmt_num]); - swapped = true; - continue; - } - - if (is_a (vinfo)) - { - /* Now for commutative ops we should see whether we can - make the other operand matching. */ - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "treating operand as external\n"); - oprnd_info->first_dt = dt = vect_external_def; - } - else - { - if (dump_enabled_p ()) - dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, - "Build SLP failed: different types\n"); - return 1; - } + /* Now for commutative ops we should see whether we can + make the other operand matching. */ + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "treating operand as external\n"); + oprnd_info->first_dt = dt = vect_external_def; + } + else + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location, + "Build SLP failed: different types\n"); + return 1; } + } /* Make sure to demote the overall operand to external. */ if (dt == vect_external_def) -- 2.30.2