[llvm] [EarlyCSE] Rematerialize alignment assumption. (PR #109131)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 01:11:01 PDT 2024


nikic wrote:

I'm still not convinced that doing something like this is a good idea. The core problem is that you can't tell whether the `!align` metadata is sufficiently valuable or not. In Rust, most pointer loads will have `!align` metadata. It's added because adding it is free and sometimes helps, but at the same time, nobody will particularly care if it gets dropped. Doing this conversion means we now have to make a tradeoff between adding the metadata, and the compile-time and optimization impact it will have.

I looked through the IR diffs, and there were plenty of minor optimization regressions and very few improvements. I think the two most common ones are:

 * Dead block not eliminated due to assume. (This is something I tried to fix in the past and it got reverted due to optimization regressions...)
 * Hoisting prevented because one block has an assume at the top and the other doesn't.

I also noticed that in some cases the same assume is repeated many times in the same block -- we should be optimizing those away.

Another interesting data point is that nearly all assumptions were redundant in the sense that they were directly followed by a load or gep+load with the same alignment. (Of course, most of our analysis cannot really use alignment on loads to reason about the alignment of the pointer at some other point.)

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


More information about the llvm-commits mailing list