[llvm] [InstCombine] Rewrite multi-use GEPs when simplifying comparison (PR #146100)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 05:15:59 PDT 2025


nikic wrote:

> This has an interesting impact on clang stage2: https://llvm-compile-time-tracker.com/compare.php?from=c503c5e26baf942773379e1b445e6730066005a9&to=a9122c1e6a652860a7636e15ae5e227538161f47&stat=instructions:u Most likely perturbing an inlining heuristic in a way that happens to be favorable.

I've investigated this, and it turned out to be runtime unrolling rather than inlining, in a fairly peculiar way. The relevant method is DenseMap::initEmpty(): https://github.com/llvm/llvm-project/blob/89fe429262933ee7fcadc717c376e7fad8a48157/llvm/include/llvm/ADT/DenseMap.h#L435-L444

The reason for the difference is that currently, runtime unrolling fails the high cost expansion check. But after this change, the offset for the last element is already calculated with a separate instruction, and thus does not count towards the expansion cost.

So I think the change there is not problematic.

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


More information about the llvm-commits mailing list