GCC with patches for OS216
Revision | d5d9f7834ab809841c4ccc90bca74808b4bcaf8d (tree) |
---|---|
Zeit | 2020-07-02 18:18:09 |
Autor | Richard Biener <rguenther@suse...> |
Commiter | Richard Biener |
tree-optimization/96022 - fix ICE with vectorized shift
This fixes lane extraction for internal def vectorized shifts
with an effective scalar shift operand by always using lane zero
of the first vector stmt.
It also fixes a SLP build issue noticed on the testcase where
we end up building unary vector ops with the only operand built
form scalars which isn't profitable by itself. The exception
is for stores.
2020-07-02 Richard Biener <rguenther@suse.de>
PR tree-optimization/96022
* tree-vect-stmts.c (vectorizable_shift): Only use the
first vector stmt when extracting the scalar shift amount.
* tree-vect-slp.c (vect_build_slp_tree_2): Also build unary
nodes with all-scalar children from scalars but not stores.
(vect_analyze_slp_instance): Mark the node not failed.
* g++.dg/vect/pr96022.cc: New testcase.
@@ -0,0 +1,12 @@ | ||
1 | +// { dg-do compile } | |
2 | +// { dg-additional-options "-O3" } | |
3 | + | |
4 | +extern int arr_6[]; | |
5 | +extern char arr_7[] __attribute__((aligned)); | |
6 | +void test(short a, bool, int p8) { | |
7 | + for (bool b = 0; b < (bool)p8; b = 1) | |
8 | + for (short c = 0; c < 5; c++) { | |
9 | + arr_6[c] = (long)2 << a - 30574; | |
10 | + arr_7[c] = 0; | |
11 | + } | |
12 | +} |
@@ -1530,11 +1530,11 @@ fail: | ||
1530 | 1530 | |
1531 | 1531 | vect_free_oprnd_info (oprnds_info); |
1532 | 1532 | |
1533 | - /* If we have all children of a non-unary child built up from | |
1534 | - uniform scalars then just throw that away, causing it built up | |
1535 | - from scalars. */ | |
1536 | - if (nops > 1 | |
1537 | - && is_a <bb_vec_info> (vinfo) | |
1533 | + /* If we have all children of a child built up from uniform scalars | |
1534 | + then just throw that away, causing it built up from scalars. | |
1535 | + The exception is the SLP node for the vector store. */ | |
1536 | + if (is_a <bb_vec_info> (vinfo) | |
1537 | + && !STMT_VINFO_GROUPED_ACCESS (stmt_info) | |
1538 | 1538 | /* ??? Rejecting patterns this way doesn't work. We'd have to |
1539 | 1539 | do extra work to cancel the pattern so the uses see the |
1540 | 1540 | scalar version. */ |
@@ -2230,6 +2230,7 @@ vect_analyze_slp_instance (vec_info *vinfo, | ||
2230 | 2230 | return false; |
2231 | 2231 | } |
2232 | 2232 | /* Fatal mismatch. */ |
2233 | + matches[0] = true; | |
2233 | 2234 | matches[group_size / const_max_nunits * const_max_nunits] = false; |
2234 | 2235 | vect_free_slp_tree (node, false); |
2235 | 2236 | } |
@@ -5403,7 +5403,7 @@ vectorizable_shift (vec_info *vinfo, | ||
5403 | 5403 | if (!op1_vectype) |
5404 | 5404 | op1_vectype = get_vectype_for_scalar_type (vinfo, |
5405 | 5405 | TREE_TYPE (op1), |
5406 | - slp_node); | |
5406 | + slp_op1); | |
5407 | 5407 | |
5408 | 5408 | /* Unlike the other binary operators, shifts/rotates have |
5409 | 5409 | the rhs being int, instead of the same type as the lhs, |
@@ -5575,11 +5575,11 @@ vectorizable_shift (vec_info *vinfo, | ||
5575 | 5575 | /* Arguments are ready. Create the new vector stmt. */ |
5576 | 5576 | FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0) |
5577 | 5577 | { |
5578 | - vop1 = vec_oprnds1[i]; | |
5579 | 5578 | /* For internal defs where we need to use a scalar shift arg |
5580 | 5579 | extract the first lane. */ |
5581 | 5580 | if (scalar_shift_arg && dt[1] == vect_internal_def) |
5582 | 5581 | { |
5582 | + vop1 = vec_oprnds1[0]; | |
5583 | 5583 | new_temp = make_ssa_name (TREE_TYPE (TREE_TYPE (vop1))); |
5584 | 5584 | gassign *new_stmt |
5585 | 5585 | = gimple_build_assign (new_temp, |
@@ -5590,6 +5590,8 @@ vectorizable_shift (vec_info *vinfo, | ||
5590 | 5590 | vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi); |
5591 | 5591 | vop1 = new_temp; |
5592 | 5592 | } |
5593 | + else | |
5594 | + vop1 = vec_oprnds1[i]; | |
5593 | 5595 | gassign *new_stmt = gimple_build_assign (vec_dest, code, vop0, vop1); |
5594 | 5596 | new_temp = make_ssa_name (vec_dest, new_stmt); |
5595 | 5597 | gimple_assign_set_lhs (new_stmt, new_temp); |