[llvm] [LSR] Deduplicate cast instructions across ICmpZero fixups (PR #201970)
Timur Golubovich via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 8 06:09:59 PDT 2026
timurgol007 wrote:
> The question here would be whether reusing casts in those cases is actually practically useful. This patch doesn't affect any of our existing test coverage, so I'd suspect the answer is "no". If it _is_ (end-to-end) useful, we should have tests for that.
I've seen this happen in SPEC sealcrypto (the test added here is reduced from that case). Without this optimization, LSR can produce multiple equivalent casts, and later simplifyInstruction can't fold the icmp because its operands end up being different cast instructions.
As far as I can tell, there's no IR-level CSE after LSR that would clean this up, so the redundancy survives and the simplification opportunity is lost. Reusing an existing cast avoids creating those duplicate expressions in the first place and lets the icmp fold as expected.
https://github.com/llvm/llvm-project/pull/201970
More information about the llvm-commits
mailing list