[llvm] [InstCombine] Allow freezing multiple operands (PR #154336)

Cullen Rhodes via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 19 09:23:18 PDT 2025


c-rhodes wrote:

> InstCombine tries to convert freeze(inst(op)) to inst(freeze(op)). Currently, this is limited to the case where a single operand needs to be frozen, and all other operands are guaranteed non-poison.

Thanks for the patch! This fixes an issue which the tests I added in https://github.com/llvm/llvm-project/pull/145541 demonstrate. I'll abandon my attempt #150420 at fixing that as this seems like a nicer approach.

> This patch allows the transform even if multiple operands need to be frozen. The existing limitation makes sure that we do not increase the total number of freezes, but it also means that that we may fail to eliminate freezes (via poison flag dropping) and may prevent optimizations (as analysis generally can't look past freeze). Overall, I believe that aggressively pushing freezes upwards is more beneficial than harmful.

Me and @david-arm also considered what you're doing here when looking at this code. I think one thing that put me off is it seemed at odds with the "total number of freezes" metric and any reduction in this being seen as a good thing. I'm not sure if my assessment there is correct, just something I observed when i started looking into this and reading old slides etc. It occurred to me perhaps it's not the number of freezes but how much of the DAG is frozen, so aggressively pushing freezes upwards makes sense to me 👍 

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


More information about the llvm-commits mailing list