Commit fbdf8ab
authored
[LSV] Merge contiguous chains across scalar types (llvm#154069)
This change enables the LoadStoreVectorizer to merge and vectorize
contiguous chains even when their scalar element types differ, as long
as the total bitwidth matches. To do so, we rebase offsets between
chains, normalize value types to a common integer type, and insert the
necessary casts around loads and stores. This uncovers more
vectorization opportunities and explains the expected codegen updates
across AMDGPU tests.
Key changes:
- Chain merging
- Build contiguous subchains and then merge adjacent ones when:
- They refer to the same underlying pointer object and address space.
- They are either all loads or all stores.
- A constant leader-to-leader delta exists.
- Rebasing one chain into the other's coordinate space does not overlap.
- All elements have equal total bit width.
- Rebase the second chain by the computed delta and append it to the
first.
- Type normalization and casting
- Normalize merged chains to a common integer type sized to the total
bits.
- For loads: create a new load of the normalized type, copy metadata,
and cast back to the original type for uses if needed.
- For stores: bitcast the value to the normalized type and store that.
- Insert zext/trunc for integer size changes; use bit-or-pointer casts
when sizes match.
- Cleanups
- Erase replaced instructions and DCE pointer operands when safe.
- New helpers: computeLeaderDelta, chainsOverlapAfterRebase,
rebaseChain, normalizeChainToType, and allElemsMatchTotalBits.
Impact:
- Increases vectorization opportunities across mixed-typed but
size-compatible access chains.
- Large set of expected AMDGPU codegen diffs due to more/changed
vectorization.
This PR resolves llvm#97715.1 parent 039f883 commit fbdf8ab
File tree
50 files changed
+3979
-2766
lines changed- llvm
- include/llvm/Transforms/Utils
- lib
- Target/AMDGPU
- Transforms
- InstCombine
- Scalar
- Utils
- Vectorize
- test
- CodeGen/AMDGPU
- GlobalISel
- Transforms
- InstCombine
- LoadStoreVectorizer/AMDGPU
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
50 files changed
+3979
-2766
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
431 | 431 | | |
432 | 432 | | |
433 | 433 | | |
434 | | - | |
| 434 | + | |
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1035 | 1035 | | |
1036 | 1036 | | |
1037 | 1037 | | |
1038 | | - | |
| 1038 | + | |
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | | - | |
| 418 | + | |
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| |||
606 | 606 | | |
607 | 607 | | |
608 | 608 | | |
609 | | - | |
| 609 | + | |
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3280 | 3280 | | |
3281 | 3281 | | |
3282 | 3282 | | |
3283 | | - | |
| 3283 | + | |
3284 | 3284 | | |
3285 | 3285 | | |
3286 | 3286 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3100 | 3100 | | |
3101 | 3101 | | |
3102 | 3102 | | |
3103 | | - | |
| 3103 | + | |
3104 | 3104 | | |
3105 | | - | |
3106 | | - | |
3107 | | - | |
3108 | | - | |
| 3105 | + | |
| 3106 | + | |
| 3107 | + | |
| 3108 | + | |
| 3109 | + | |
| 3110 | + | |
| 3111 | + | |
| 3112 | + | |
| 3113 | + | |
| 3114 | + | |
3109 | 3115 | | |
3110 | 3116 | | |
3111 | 3117 | | |
3112 | | - | |
3113 | | - | |
3114 | | - | |
3115 | | - | |
3116 | | - | |
3117 | | - | |
3118 | | - | |
| 3118 | + | |
3119 | 3119 | | |
| 3120 | + | |
3120 | 3121 | | |
3121 | | - | |
3122 | 3122 | | |
3123 | | - | |
3124 | 3123 | | |
3125 | | - | |
3126 | 3124 | | |
3127 | 3125 | | |
3128 | 3126 | | |
3129 | | - | |
3130 | 3127 | | |
3131 | 3128 | | |
3132 | 3129 | | |
3133 | | - | |
3134 | | - | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
3135 | 3139 | | |
3136 | 3140 | | |
3137 | 3141 | | |
3138 | | - | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
3139 | 3146 | | |
3140 | 3147 | | |
3141 | 3148 | | |
3142 | 3149 | | |
3143 | 3150 | | |
3144 | | - | |
| 3151 | + | |
| 3152 | + | |
3145 | 3153 | | |
3146 | | - | |
| 3154 | + | |
3147 | 3155 | | |
3148 | 3156 | | |
3149 | 3157 | | |
3150 | | - | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
3151 | 3167 | | |
3152 | 3168 | | |
3153 | 3169 | | |
| |||
0 commit comments