[llvm] [GlobalISel] Don't push `freeze`s post-legalizer when that creates illegal instruction (PR #204785)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 24 03:39:01 PDT 2026
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>,
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>,
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>,
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>,
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>,
=?utf-8?q?Ömer_Sinan_Ağacan?= <omeragacan at gmail.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/204785 at github.com>
davemgreen wrote:
> So I'd actually considered this, but the legalization of `G_FREEZE` is quite complex and I wasn't sure if/how it should be updated.
>
> Naively I'd think that `freeze(op)` should be valid iff `op` is valid, but IIUC that's not possible to express with the `getActionDefinitionsBuilder` API.
Some operations like freeze should be legal for all types legal for other operations. G_IMPLICIT_DEF is the same, you sometimes just need to generate them. I think G_CONSTANT_FOLD_BARRIER can be handled the same too.
> If we want to update legalization to allow `s128` that also fixes this issue, but we'd also have to update some of the other rules like `clampScalar(0, s8, s64)` and maybe also `scalarizeIf(scalarOrEltWiderThan(0, 64), 0)`. And then another question is whether `G_IMPLICIT_DEF` and `G_CONSTANT_FOLD_BARRIER` legalization should still be in the same as `G_FREEZE` legalization or they should be separated now.
They can probably be treated similarly. clampScalar I'm not sure about but just making the s128 legal might be enough.
https://github.com/llvm/llvm-project/pull/204785
More information about the llvm-commits
mailing list