[clang] [llvm] [InferAlignment] Propagate alignment between loads/stores of the same base pointer (PR #145733)

Drew Kersnar via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 6 09:30:23 PDT 2025


dakersnar wrote:

I think you're right. Since the only thing that really matters for commonAlignment is the number of trailing zeros of each input, we can generalize whether we need the `abs` to the following statement: "will a number and it's two's compliment always have the same number of trailing zeros?". And the answer is yes, because negating will turn the least significant 1 followed by trailing 0s into a 0 followed by trailing 1s, and then adding 1 will revert those bits back to the original pattern, leaving the same number of trailing zeros.

Is there any merit to keeping the abs for readability, so future maintainers don't need to reason through this? Maybe just a comment?

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


More information about the llvm-commits mailing list