LDS is allocated to 64-dword alignment. In order to prove a memory address being 8 byte aligned it is sufficient to check that the offset if multiple of 8.
This allows generating ds_read/write_b64 instead of ds_read/write2_b32.
It is not immediately clear to me if the base pointer is always an LDS allocated symbol. I guess it can also be a GEP, right?
Let's consider the situation:
sym is a 64-dword aligned LDS allocation.
I suppose for the gep2 your logic will incorrectly report 8 byte alignment.
I think it is simpler than that. If a local symbol must be 64 dword aligned, it should be declared as a such and not 4 byte aligned as we have.
Such logic shall not be needed at the first place, llvm should be able to deduce proper alignment given proper input.
Although I am not really sure this is true it is always 64 dword aligned. Consider:
local int x;
local int y;
Do you mean this allocation would take 128 dwords? I highly doubt.
I suppose only the first symbol is 64 dword aligned, and everything after is just naturally aligned wrt element type size. So a logic to leverage actual allocation alignment can be useful only after all LDS is allocated and allocation is flattened into a single LDS memory array.
Also if you're referring to the allocation granularity for the entire program, that doesn't reflect the individual symbols allocated. We certainly don't allocate the individual globals with at least 8 byte alignment