[llvm] [LAA] getPointersDiff(): Add ExpensivePtrCheck argument (PR #226333)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 25 13:19:49 PDT 2026


nikic wrote:

It's not fully precise, but it is intended to catch practically relevant cases.

For your example, the relevant parts of the SCEV expressions are:
```
4 * ((8192 * %val) + (131072 * (zext i3 (trunc i64 %val to i3) to i64))<nuw><nsw> + %or)
4 + (4 * %or) + (32768 * %val) + (524288 * (zext i3 (trunc i64 %val to i3) to i64))<nuw><nsw>
```
It seems like SCEV should canonicalize the former by distributing the multiply over the add, which can fold into the multiplies for all but the `%or` operand, so preserves number of multiplies. It looks like the code that does this is special cased for adds with two operands, thus the difference in behavior between the two indices...

-----

Where are you planning to use this new option?

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


More information about the llvm-commits mailing list