Skip to content

Commit 5ff68a4

Browse files
rguenthFrosty515
authored andcommitted
tree-optimization/114799 - SLP and patterns
The following plugs a hole with computing whether a SLP node has any pattern stmts which is important to know when we want to replace it by a CTOR from external defs. PR tree-optimization/114799 * tree-vect-slp.cc (vect_get_and_check_slp_defs): Properly update ->any_pattern when swapping operands. * gcc.dg/vect/bb-slp-pr114799.c: New testcase. (cherry picked from commit 18e8e55)
1 parent 464b19e commit 5ff68a4

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* { dg-do compile } */
2+
/* { dg-additional-options "-fno-tree-forwprop" } */
3+
4+
unsigned long x;
5+
unsigned char y;
6+
7+
void
8+
foo (void)
9+
{
10+
unsigned long tt = y;
11+
tt+=255;
12+
unsigned short t1 = tt;
13+
t1 = 254 - t1;
14+
tt += ((unsigned long)t1);
15+
x = tt;
16+
}

gcc/tree-vect-slp.cc

+6
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,12 @@ vect_get_and_check_slp_defs (vec_info *vinfo, unsigned char swap,
774774
(*oprnds_info)[i+1]->def_stmts[stmt_num]);
775775
std::swap ((*oprnds_info)[i]->ops[stmt_num],
776776
(*oprnds_info)[i+1]->ops[stmt_num]);
777+
/* After swapping some operands we lost track whether an
778+
operand has any pattern defs so be conservative here. */
779+
if ((*oprnds_info)[i]->any_pattern
780+
|| (*oprnds_info)[i+1]->any_pattern)
781+
(*oprnds_info)[i]->any_pattern
782+
= (*oprnds_info)[i+1]->any_pattern = true;
777783
swapped = true;
778784
continue;
779785
}

0 commit comments

Comments
 (0)