[llvm] [SPIR-V] Add lowering for G_FSINCOS (PR #179053)
Dmitry Sidorov via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 2 04:45:48 PST 2026
================
@@ -1409,6 +1413,71 @@ bool SPIRVInstructionSelector::selectFrexp(Register ResVReg,
return false;
}
+bool SPIRVInstructionSelector::selectSincos(Register ResVReg,
+ const SPIRVType *ResType,
+ MachineInstr &I) const {
+ Register CosResVReg = I.getOperand(1).getReg();
+ unsigned SrcIdx = I.getNumExplicitDefs();
+ Register ResTypeReg = GR.getSPIRVTypeID(ResType);
+
+ if (STI.canUseExtInstSet(SPIRV::InstructionSet::OpenCL_std)) {
+ // OpenCL.std sincos(x, cosval*) -> returns sin(x), writes cos(x) to ptr.
+ MachineIRBuilder MIRBuilder(I);
+ const SPIRVType *PointerType = GR.getOrCreateSPIRVPointerType(
+ ResType, MIRBuilder, SPIRV::StorageClass::Function);
+ Register PointerVReg =
+ createVirtualRegister(PointerType, &GR, MRI, MRI->getMF());
+
+ auto It = getOpVariableMBBIt(I);
+ auto MIB = BuildMI(*It->getParent(), It, It->getDebugLoc(),
----------------
MrSidims wrote:
Yeah, I also find this a bit confusing, but that is the style of other functions in the file, so I used it. Applied your suggestion.
https://github.com/llvm/llvm-project/pull/179053
More information about the llvm-commits
mailing list