[llvm] [InstCombine] Limit canonicalization of extractelement(cast) to constant index or same basic block. (PR #166227)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 5 22:15:20 PST 2025


nikic wrote:

Usually the way we handle transforms that may be non-profitable due to code motion into loops is via an undo transform in LICM (which intentionally has a late, post-InstCombine run scheduled). We could add a "LICM with reassociation" transform that converts extractelement + fptosi to fptosi + extractelement if this allows the fptosi to be LICMed. With the usual benefit that it will also fix the problem if the IR was originally in this form, rather than introduced by InstCombine. However, as that creates a vector op from a scalar op that would probably need cost modelling as well, which we don't usually do in LICM.

I think overall this is fine for now, we can try to do better if this causes regressions or something.

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


More information about the llvm-commits mailing list