[llvm] [AArch64][GlobalISel] Extend scalar lrint legalization. (PR #88360)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 13 08:16:49 PDT 2024
================
@@ -1059,6 +1061,26 @@ LegalizerHelper::libcall(MachineInstr &MI, LostDebugLocObserver &LocObserver) {
return Status;
break;
}
+ case TargetOpcode::G_INTRINSIC_LRINT: {
+ LLT LLTy = MRI.getType(MI.getOperand(1).getReg());
+ unsigned Size = LLTy.getSizeInBits();
+ Type *HLTy = getFloatTypeForLLT(Ctx, LLTy);
+ Type *ITy = IntegerType::get(
+ Ctx, MRI.getType(MI.getOperand(0).getReg()).getSizeInBits());
+ if (!HLTy || (Size != 32 && Size != 64 && Size != 80 && Size != 128)) {
+ LLVM_DEBUG(dbgs() << "No libcall available for type " << LLTy << ".\n");
+ return UnableToLegalize;
+ }
+ auto Libcall = getRTLibDesc(MI.getOpcode(), Size);
+ SmallVector<CallLowering::ArgInfo, 2> Args;
+ Args.push_back({MI.getOperand(1).getReg(), HLTy, 0});
+ LegalizeResult Status =
+ createLibcall(MIRBuilder, Libcall, {MI.getOperand(0).getReg(), ITy, 0},
+ Args, LocObserver, &MI);
+ if (Status != Legalized)
+ return Status;
+ break;
----------------
davemgreen wrote:
SGTM, thanks. I don't mind changing the others too if you think it's a good idea.
https://github.com/llvm/llvm-project/pull/88360
More information about the llvm-commits
mailing list