Commit 7a8a9b0
committed
[LV] Stop using the legacy cost model for udiv + friends
In VPWidenRecipe::computeCost for the instructions udiv, sdiv,
urem and srem we fall back on the legacy cost unnecessarily. At
this point we know that the vplan must be functionally correct, i.e.
if the divide/remainder is not safe to speculatively execute then
we must have either:
1. Scalarised the operation, in which case we wouldn't be using
a VPWidenRecipe, or
2. We've inserted a select for the second operand to ensure we
don't fault through divide-by-zero.
For 2) it's necessary to add the select operation to
VPInstruction::computeCost so that we mirror the cost of the
legacy cost model. The only problem with this is that we also
generate selects in vplan for predicated loops with reductions,
which *aren't* accounted for in the legacy cost model. In order
to prevent asserts firing I've also added the selects to
precomputeCosts to ensure the legacy costs match the vplan costs
for reductions.1 parent ffe21f1 commit 7a8a9b0
File tree
2 files changed
+16
-3
lines changed- llvm/lib/Transforms/Vectorize
2 files changed
+16
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4278 | 4278 | | |
4279 | 4279 | | |
4280 | 4280 | | |
| 4281 | + | |
| 4282 | + | |
| 4283 | + | |
4281 | 4284 | | |
4282 | 4285 | | |
4283 | 4286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1029 | 1029 | | |
1030 | 1030 | | |
1031 | 1031 | | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
1032 | 1041 | | |
1033 | 1042 | | |
1034 | 1043 | | |
| |||
2099 | 2108 | | |
2100 | 2109 | | |
2101 | 2110 | | |
2102 | | - | |
2103 | | - | |
2104 | | - | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
2105 | 2115 | | |
2106 | 2116 | | |
2107 | 2117 | | |
| |||
0 commit comments