Commit e90f463
authored
[SLP] Normalize copyable operand order via majority voting
When building operands for entries with copyable elements, non-copyable
lanes of commutative ops may have inconsistent operand order (e.g. some
lanes have load,add while others have add,load). This prevents
VLOperands::reorder() from grouping consecutive loads on one side,
degrading downstream vectorization.
Add majority-voting normalization during buildOperands: track the
(ValueID, ValueID) pair frequency across non-copyable lanes and swap
any lane whose operand types are the exact inverse of the most common
pattern. This makes operand order consistent, enabling better load
grouping.
This is part 1 of #189181.
Reviewers: RKSimon, hiraditya
Pull Request: #1916311 parent 7328b74 commit e90f463
5 files changed
Lines changed: 80 additions & 29 deletions
File tree
- llvm
- lib/Transforms/Vectorize
- test/Transforms/SLPVectorizer/X86
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12029 | 12029 | | |
12030 | 12030 | | |
12031 | 12031 | | |
| 12032 | + | |
| 12033 | + | |
12032 | 12034 | | |
12033 | 12035 | | |
| 12036 | + | |
| 12037 | + | |
| 12038 | + | |
| 12039 | + | |
| 12040 | + | |
| 12041 | + | |
| 12042 | + | |
| 12043 | + | |
| 12044 | + | |
| 12045 | + | |
12034 | 12046 | | |
12035 | 12047 | | |
12036 | 12048 | | |
12037 | 12049 | | |
| 12050 | + | |
| 12051 | + | |
| 12052 | + | |
| 12053 | + | |
| 12054 | + | |
| 12055 | + | |
| 12056 | + | |
| 12057 | + | |
| 12058 | + | |
| 12059 | + | |
| 12060 | + | |
| 12061 | + | |
| 12062 | + | |
| 12063 | + | |
| 12064 | + | |
| 12065 | + | |
| 12066 | + | |
| 12067 | + | |
| 12068 | + | |
| 12069 | + | |
| 12070 | + | |
| 12071 | + | |
| 12072 | + | |
| 12073 | + | |
| 12074 | + | |
| 12075 | + | |
| 12076 | + | |
| 12077 | + | |
| 12078 | + | |
| 12079 | + | |
| 12080 | + | |
| 12081 | + | |
| 12082 | + | |
| 12083 | + | |
| 12084 | + | |
| 12085 | + | |
| 12086 | + | |
| 12087 | + | |
| 12088 | + | |
| 12089 | + | |
| 12090 | + | |
| 12091 | + | |
| 12092 | + | |
| 12093 | + | |
| 12094 | + | |
| 12095 | + | |
12038 | 12096 | | |
12039 | 12097 | | |
12040 | 12098 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
Lines changed: 9 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
157 | 148 | | |
158 | 149 | | |
159 | 150 | | |
| |||
Lines changed: 11 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | | - | |
21 | 19 | | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
28 | 23 | | |
29 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
30 | 32 | | |
31 | 33 | | |
32 | 34 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
0 commit comments