summaryrefslogtreecommitdiff
path: root/gcc/tree-vect-slp.c
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2020-01-06 18:00:15 +0000
committerRichard Sandiford <rsandifo@gcc.gnu.org>2020-01-06 18:00:15 +0000
commita0643f028e43aa2a5b09907295ecaadedac2d295 (patch)
treebe2c3cd841d6c76521bace096462f0309b2d060f /gcc/tree-vect-slp.c
parent8a0ae3c130cd1e6beb0087a6967d33d8203f0dce (diff)
Require equal shift amounts for IFN_DIV_POW2
IFN_DIV_POW2 currently requires all elements to be shifted by the same amount, in a similar way as for WIDEN_LSHIFT_EXPR. This patch enforces that when building the SLP tree. If in future targets want to support IFN_DIV_POW2 without this restriction, we'll probably need the kind of vector-vector/ vector-scalar split that we already have for normal shifts. 2020-01-06 Richard Sandiford <richard.sandiford@arm.com> gcc/ * tree-vect-slp.c (vect_build_slp_tree_1): Require all shifts in an IFN_DIV_POW2 node to be equal. gcc/testsuite/ * gcc.target/aarch64/sve/asrdiv_1.c: Remove trailing %s. * gcc.target/aarch64/sve/asrdiv_2.c: New test. * gcc.target/aarch64/sve/asrdiv_3.c: Likewise. From-SVN: r279908
Diffstat (limited to 'gcc/tree-vect-slp.c')
-rw-r--r--gcc/tree-vect-slp.c30
1 files changed, 21 insertions, 9 deletions
diff --git a/gcc/tree-vect-slp.c b/gcc/tree-vect-slp.c
index e9bd884597d..9cb724b95ae 100644
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -885,7 +885,8 @@ vect_build_slp_tree_1 (unsigned char *swap,
&& !vect_update_shared_vectype (stmt_info, vectype))
continue;
- if (gcall *call_stmt = dyn_cast <gcall *> (stmt))
+ gcall *call_stmt = dyn_cast <gcall *> (stmt);
+ if (call_stmt)
{
rhs_code = CALL_EXPR;
@@ -971,6 +972,12 @@ vect_build_slp_tree_1 (unsigned char *swap,
need_same_oprnds = true;
first_op1 = gimple_assign_rhs2 (stmt);
}
+ else if (call_stmt
+ && gimple_call_internal_p (call_stmt, IFN_DIV_POW2))
+ {
+ need_same_oprnds = true;
+ first_op1 = gimple_call_arg (call_stmt, 1);
+ }
}
else
{
@@ -1008,15 +1015,20 @@ vect_build_slp_tree_1 (unsigned char *swap,
continue;
}
- if (need_same_oprnds
- && !operand_equal_p (first_op1, gimple_assign_rhs2 (stmt), 0))
+ if (need_same_oprnds)
{
- if (dump_enabled_p ())
- dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
- "Build SLP failed: different shift "
- "arguments in %G", stmt);
- /* Mismatch. */
- continue;
+ tree other_op1 = (call_stmt
+ ? gimple_call_arg (call_stmt, 1)
+ : gimple_assign_rhs2 (stmt));
+ if (!operand_equal_p (first_op1, other_op1, 0))
+ {
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+ "Build SLP failed: different shift "
+ "arguments in %G", stmt);
+ /* Mismatch. */
+ continue;
+ }
}
if (!load_p && rhs_code == CALL_EXPR)