Commit f60eec5
authored
[VectorCombine] foldPermuteOfBinops - support multi-use binary ops and operands in shuffle folding (#173153)
Fixes #173033
This patch extends VectorCombine to fold binary operations through
shuffles in scenarios involving multiple uses of both the binary
operator and its operands.
Previously, the transformation was restricted to single-use cases to
prevent instruction duplication. This change implements a cost-based
evaluation that allows the fold even when:
1. The binary operator has multiple users (requiring duplication of the
arithmetic instruction).
2. The operands of the binary operator (the shuffles) have multiple
users (requiring the original shuffles to be preserved).
The optimization is performed if the TTI cost of the new instruction
sequence—including any duplicated arithmetic—is lower than the cost of
the shuffle sequence it replaces. This is particularly beneficial on X86
targets for expensive cross-lane shuffles.1 parent b785c99 commit f60eec5
File tree
2 files changed
+64
-19
lines changed- llvm
- lib/Transforms/Vectorize
- test/Transforms/VectorCombine/X86
2 files changed
+64
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2280 | 2280 | | |
2281 | 2281 | | |
2282 | 2282 | | |
2283 | | - | |
2284 | | - | |
| 2283 | + | |
2285 | 2284 | | |
2286 | 2285 | | |
2287 | 2286 | | |
| |||
2290 | 2289 | | |
2291 | 2290 | | |
2292 | 2291 | | |
2293 | | - | |
2294 | | - | |
2295 | | - | |
2296 | | - | |
2297 | | - | |
2298 | | - | |
| 2292 | + | |
| 2293 | + | |
| 2294 | + | |
| 2295 | + | |
2299 | 2296 | | |
2300 | 2297 | | |
2301 | 2298 | | |
| |||
2340 | 2337 | | |
2341 | 2338 | | |
2342 | 2339 | | |
| 2340 | + | |
2343 | 2341 | | |
| 2342 | + | |
| 2343 | + | |
2344 | 2344 | | |
2345 | | - | |
2346 | | - | |
2347 | | - | |
2348 | | - | |
2349 | | - | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
2350 | 2353 | | |
2351 | 2354 | | |
2352 | | - | |
2353 | | - | |
2354 | | - | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
2355 | 2362 | | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
2356 | 2367 | | |
2357 | | - | |
2358 | | - | |
| 2368 | + | |
2359 | 2369 | | |
2360 | 2370 | | |
2361 | 2371 | | |
| |||
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | 67 | | |
69 | 68 | | |
70 | 69 | | |
| |||
101 | 100 | | |
102 | 101 | | |
103 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
104 | 139 | | |
105 | 140 | | |
106 | 141 | | |
| |||
0 commit comments