Commit 73f6e22
committed
[RISCV] Match vcompress during shuffle lowering
This change matches a subset of vcompress patterns during shuffle lowering.
The subset implemented requires a contiguous prefix of demanded elements
followed by undefs. This subset was chosen for two reasons: 1) which
elements to spurious demand is a non-obvious problem, and 2) my first
several attempts at implementing the general case were buggy. I decided
to go with the simple case to start with.
vcompress scales better with LMUL than a general vrgather, and at least
the SpaceMit X60, has higher throughput even at m1. It also has the
advantage of requiring smaller vector constants at one bit per element
as opposed to vrgather which is a minimum of 8 bits per element. The
downside to using vcompress is that we can't fold a vselect into it,
as there is no masked vcompress variant.
For reference, here are the relevant throughputs from camel-cdr's data
table on BP3 (X60):
vrgather.vv v8,v16,v24 4.0 16.0 64.0 256.0
vcompress.vm v8,v16,v24 3.0 10.0 36.0 136.
vmerge.vvm v8,v16,v24,v0 2.0 4.0 8.0 16.0
The largest concern with the extra vmerge is that we locally increase
register pressure. If we do have masking, we also have a passthru,
without the ability to fold that into the vcompress, we need to keep it
alive a bit longer. This can hurt at e.g. m8 where we have very few
architectural registers. As compared with the vrgather.vv sequence,
this is only one additional m1 VREG - since we no longer need the
index vector. It compares slightly worse against vrgatherie16.vv which
can use index vectors smaller than other operands. Note that we could
potentially fold the vmerge if only tail elements are being preserved;
I haven't investigated this.
It is unfortunately hard given our current lowering structure to
know if we're emitting a shuffle where masking will follow. Thankfully,
it doesn't seem to show up much in practice, so I think we can probably
ignore it.
This patch only handles single source compress idioms at the moment.
This is an effort to avoid interacting with other patches on review
for changing how we canonicalize length changing shuffles.1 parent c94d715 commit 73f6e22
File tree
8 files changed
+784
-695
lines changed- llvm
- lib/Target/RISCV
- test/CodeGen/RISCV/rvv
8 files changed
+784
-695
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5155 | 5155 | | |
5156 | 5156 | | |
5157 | 5157 | | |
| 5158 | + | |
| 5159 | + | |
| 5160 | + | |
| 5161 | + | |
| 5162 | + | |
| 5163 | + | |
| 5164 | + | |
| 5165 | + | |
| 5166 | + | |
| 5167 | + | |
| 5168 | + | |
| 5169 | + | |
| 5170 | + | |
| 5171 | + | |
| 5172 | + | |
| 5173 | + | |
| 5174 | + | |
| 5175 | + | |
| 5176 | + | |
| 5177 | + | |
| 5178 | + | |
| 5179 | + | |
5158 | 5180 | | |
5159 | 5181 | | |
5160 | 5182 | | |
| |||
5372 | 5394 | | |
5373 | 5395 | | |
5374 | 5396 | | |
| 5397 | + | |
| 5398 | + | |
| 5399 | + | |
| 5400 | + | |
| 5401 | + | |
| 5402 | + | |
| 5403 | + | |
| 5404 | + | |
| 5405 | + | |
| 5406 | + | |
| 5407 | + | |
| 5408 | + | |
| 5409 | + | |
| 5410 | + | |
| 5411 | + | |
| 5412 | + | |
| 5413 | + | |
| 5414 | + | |
| 5415 | + | |
5375 | 5416 | | |
5376 | 5417 | | |
5377 | 5418 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
44 | 45 | | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
45 | 49 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | 50 | | |
52 | | - | |
| 51 | + | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
138 | 138 | | |
139 | 139 | | |
140 | 140 | | |
141 | | - | |
142 | | - | |
143 | 141 | | |
144 | 142 | | |
145 | | - | |
146 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
147 | 148 | | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| |||
Lines changed: 17 additions & 18 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
117 | | - | |
118 | | - | |
| 116 | + | |
| 117 | + | |
119 | 118 | | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
124 | 122 | | |
125 | 123 | | |
126 | 124 | | |
| |||
723 | 721 | | |
724 | 722 | | |
725 | 723 | | |
726 | | - | |
| 724 | + | |
727 | 725 | | |
728 | 726 | | |
729 | 727 | | |
730 | | - | |
731 | | - | |
732 | | - | |
733 | | - | |
734 | | - | |
735 | | - | |
736 | | - | |
737 | | - | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
738 | 737 | | |
739 | | - | |
740 | | - | |
| 738 | + | |
| 739 | + | |
741 | 740 | | |
742 | 741 | | |
743 | 742 | | |
| |||
0 commit comments