• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GCC with patches for OS216


Commit MetaInfo

Revisiond5d9f7834ab809841c4ccc90bca74808b4bcaf8d (tree)
Zeit2020-07-02 18:18:09
AutorRichard Biener <rguenther@suse...>
CommiterRichard Biener

Log Message

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.

Ändern Zusammenfassung

Diff

--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr96022.cc
@@ -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+}
--- a/gcc/tree-vect-slp.c
+++ b/gcc/tree-vect-slp.c
@@ -1530,11 +1530,11 @@ fail:
15301530
15311531 vect_free_oprnd_info (oprnds_info);
15321532
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)
15381538 /* ??? Rejecting patterns this way doesn't work. We'd have to
15391539 do extra work to cancel the pattern so the uses see the
15401540 scalar version. */
@@ -2230,6 +2230,7 @@ vect_analyze_slp_instance (vec_info *vinfo,
22302230 return false;
22312231 }
22322232 /* Fatal mismatch. */
2233+ matches[0] = true;
22332234 matches[group_size / const_max_nunits * const_max_nunits] = false;
22342235 vect_free_slp_tree (node, false);
22352236 }
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -5403,7 +5403,7 @@ vectorizable_shift (vec_info *vinfo,
54035403 if (!op1_vectype)
54045404 op1_vectype = get_vectype_for_scalar_type (vinfo,
54055405 TREE_TYPE (op1),
5406- slp_node);
5406+ slp_op1);
54075407
54085408 /* Unlike the other binary operators, shifts/rotates have
54095409 the rhs being int, instead of the same type as the lhs,
@@ -5575,11 +5575,11 @@ vectorizable_shift (vec_info *vinfo,
55755575 /* Arguments are ready. Create the new vector stmt. */
55765576 FOR_EACH_VEC_ELT (vec_oprnds0, i, vop0)
55775577 {
5578- vop1 = vec_oprnds1[i];
55795578 /* For internal defs where we need to use a scalar shift arg
55805579 extract the first lane. */
55815580 if (scalar_shift_arg && dt[1] == vect_internal_def)
55825581 {
5582+ vop1 = vec_oprnds1[0];
55835583 new_temp = make_ssa_name (TREE_TYPE (TREE_TYPE (vop1)));
55845584 gassign *new_stmt
55855585 = gimple_build_assign (new_temp,
@@ -5590,6 +5590,8 @@ vectorizable_shift (vec_info *vinfo,
55905590 vect_finish_stmt_generation (vinfo, stmt_info, new_stmt, gsi);
55915591 vop1 = new_temp;
55925592 }
5593+ else
5594+ vop1 = vec_oprnds1[i];
55935595 gassign *new_stmt = gimple_build_assign (vec_dest, code, vop0, vop1);
55945596 new_temp = make_ssa_name (vec_dest, new_stmt);
55955597 gimple_assign_set_lhs (new_stmt, new_temp);