[llvm] [DSE] Split memory intrinsics if they are dead in the middle (PR #75478)

Nabeel Omer via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 6 00:48:03 PST 2024


omern1 wrote:

Hi @bjope,

Thanks for looking at this.

> The already existing helpers for trimming the start (tryToShorten) is involving some logic for atomic operations. I wonder if that is needed here as well (a bit unsure since the helper for trimming the end (tryToShortenEnd) isn't having any extra logic for atomics. So maybe it isn't needed, but perhaps something to look into unless you've figured out that it isn't needed.

I've looked at this now and I think the logic for trimming atomic operations is required here as well. I'll add it shortly.

>  find the (DeadSize >= Threshold) requirement a bit restrictive (at least for us). One example would be if we have a memset writing X+Y+X bytes, with the Y bytes in the middle being dead. If for example X=8 and Y=1, then doing the split would result in two 8 byte stores, while a memset of 17 bytes would require 3 stores (in this example I assume that the target can do stores with align=1). So even if we normally would inline such a memset, it would be profitable to split it up and skip writing the middle Y bytes as the front/rear would be cheaper as the sizes are well-aligned.

This is a good point, I'm inclined to add a check to let the transform run when `Front` and `Rear` are aligned.


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


More information about the llvm-commits mailing list