Commit 26ecf97
authored
[LoopVectorize] Further improve cost model for early exit loops (#126235)
Following on from #125058, this patch takes into account the
work done in the vector early exit block when assessing the
profitability of vectorising the loop. I have renamed
areRuntimeChecksProfitable to isOutsideLoopWorkProfitable and
we now pass in the early exit costs. As part of this, I have
added the ExtractFirstActive opcode to VPInstruction::computeCost.
It's worth pointing out that when we assess profitability of the
loop we calculate a minimum trip count and compare that against
the *maximum* trip count. However, since the loop has an early
exit the runtime trip count can still end up being less than the
minimum. Alternatively, we may never take the early exit at all
at runtime and so we have the opposite problem of over-estimating
the cost of the loop. The loop vectoriser cannot simultaneously
take two contradictory positions and so I feel the only sensible
thing to do is be conservative and assume the loop will be more
expensive than loops without early exits.
We may find in future that we need to adjust the cost according to
the probability of taking the early exit. This will become even
more important once we support multiple early exits. However, we
have to start somewhere and we can always revisit this later.1 parent 63635c1 commit 26ecf97
File tree
4 files changed
+155
-14
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/LoopVectorize/AArch64
4 files changed
+155
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10171 | 10171 | | |
10172 | 10172 | | |
10173 | 10173 | | |
10174 | | - | |
10175 | | - | |
10176 | | - | |
10177 | | - | |
10178 | | - | |
10179 | | - | |
10180 | | - | |
| 10174 | + | |
| 10175 | + | |
| 10176 | + | |
| 10177 | + | |
| 10178 | + | |
| 10179 | + | |
| 10180 | + | |
| 10181 | + | |
| 10182 | + | |
| 10183 | + | |
| 10184 | + | |
| 10185 | + | |
| 10186 | + | |
| 10187 | + | |
| 10188 | + | |
| 10189 | + | |
| 10190 | + | |
| 10191 | + | |
| 10192 | + | |
| 10193 | + | |
| 10194 | + | |
| 10195 | + | |
| 10196 | + | |
| 10197 | + | |
| 10198 | + | |
| 10199 | + | |
| 10200 | + | |
| 10201 | + | |
| 10202 | + | |
| 10203 | + | |
| 10204 | + | |
| 10205 | + | |
| 10206 | + | |
| 10207 | + | |
| 10208 | + | |
| 10209 | + | |
| 10210 | + | |
| 10211 | + | |
| 10212 | + | |
10181 | 10213 | | |
10182 | 10214 | | |
| 10215 | + | |
| 10216 | + | |
| 10217 | + | |
| 10218 | + | |
10183 | 10219 | | |
10184 | 10220 | | |
10185 | 10221 | | |
10186 | | - | |
| 10222 | + | |
| 10223 | + | |
10187 | 10224 | | |
10188 | 10225 | | |
10189 | 10226 | | |
| |||
10209 | 10246 | | |
10210 | 10247 | | |
10211 | 10248 | | |
10212 | | - | |
| 10249 | + | |
| 10250 | + | |
| 10251 | + | |
10213 | 10252 | | |
10214 | 10253 | | |
10215 | 10254 | | |
| |||
10227 | 10266 | | |
10228 | 10267 | | |
10229 | 10268 | | |
10230 | | - | |
| 10269 | + | |
10231 | 10270 | | |
10232 | 10271 | | |
10233 | 10272 | | |
| |||
10555 | 10594 | | |
10556 | 10595 | | |
10557 | 10596 | | |
10558 | | - | |
10559 | | - | |
| 10597 | + | |
| 10598 | + | |
10560 | 10599 | | |
10561 | 10600 | | |
10562 | 10601 | | |
| |||
10654 | 10693 | | |
10655 | 10694 | | |
10656 | 10695 | | |
| 10696 | + | |
| 10697 | + | |
10657 | 10698 | | |
10658 | | - | |
10659 | | - | |
| 10699 | + | |
| 10700 | + | |
| 10701 | + | |
10660 | 10702 | | |
10661 | 10703 | | |
10662 | 10704 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
742 | 742 | | |
743 | 743 | | |
744 | 744 | | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
745 | 757 | | |
746 | 758 | | |
747 | 759 | | |
| |||
Lines changed: 86 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| 277 | + | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
| |||
0 commit comments