[llvm] [AArch64] Lower to FRINTZ instructions (PR #198477)
Jacob Crawley via llvm-commits
llvm-commits at lists.llvm.org
Thu May 28 03:15:32 PDT 2026
jacob-crawley wrote:
> I think adding a new combine may be unnecessary here (sorry!). The existing combine that applies for NEON is `foldFPToIntToFP` (in DAGCombiner.cpp). It folds fptosi -> sitofp pairs to `ISD::FTRUNC`. The reason this does not kick in for SVE is it's gated on `TLI.isOperationLegal(ISD::FTRUNC, VT)`. This is fine for NEON (as the operations are marked Legal), for SVE FTRUNC is "Custom" (as we need to lower it to a masked operation), so this check fails. If we could change the check to `isOperationLegalOrCustom`, I think we'd get this combine for "free".
>
> https://github.com/llvm/llvm-project/blob/38555dbd81ad2dcfc452d29151299d829095258b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp#L19949-L19962
Thanks @MacDue this is correct. I've been able to achieve the same lowering to `frintz` by removing the new combine function and modifying `foldFPToIntToFP`.
https://github.com/llvm/llvm-project/pull/198477
More information about the llvm-commits
mailing list