[llvm] [AggressiveInstCombine] Support store merge with non-consecutive parts (PR #149807)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 22 01:14:36 PDT 2025


nikic wrote:

> However, I have a question for the remaining FIXME:
> 
> > FIXME: We could generate smaller stores if we can't produce a large one.
> 
> Imagine we have three consecutive stores:
> 
> ```
> store 0 | store 1 | store 2
>         ^
>         |
>       aligned to 2 bytes
> ```
> 
> Fast unaligned memory access may not be as fast as aligned access because the former one may access multiple cache lines. In this case, `store i8 + store i16` is better than `store i16 + store i8`. So I don't think that a greedy strategy like this patch works well.

I think this can be mostly addressed by only combining stores, but not trying to split them up in new ways. So if we have stores i8, i16 we would not try to rewrite them to i16, i8. This does mean we'd also exclude rewriting i8, i16, i8 to i16, i16 (for the hypothetical case where unaligned i32 store is not supported).

https://github.com/llvm/llvm-project/pull/149807


More information about the llvm-commits mailing list