Skip to content

Commit 9010ac8

Browse files
author
test
committed
waveid
1 parent f6ded0b commit 9010ac8

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

llvm/include/llvm/IR/IntrinsicsAMDGPU.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2839,6 +2839,9 @@ def int_amdgcn_global_load_lds : AMDGPUGlobalLoadLDS;
28392839
def int_amdgcn_pops_exiting_wave_id :
28402840
DefaultAttrsIntrinsic<[llvm_i32_ty], [], [IntrNoMem, IntrHasSideEffects]>;
28412841

2842+
// i32 @llvm.amdgcn.gfx9_wave_id(i32)
2843+
def int_amdgcn_gfx9_wave_id : DefaultAttrsIntrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem, IntrConvergent]>;
2844+
28422845
//===----------------------------------------------------------------------===//
28432846
// GFX10 Intrinsics
28442847
//===----------------------------------------------------------------------===//

llvm/lib/Target/AMDGPU/SIISelLowering.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9874,6 +9874,20 @@ SDValue SITargetLowering::LowerINTRINSIC_WO_CHAIN(SDValue Op,
98749874
: DAG.getPOISON(VT);
98759875
case Intrinsic::amdgcn_wave_id:
98769876
return lowerWaveID(DAG, Op);
9877+
case Intrinsic::amdgcn_gfx9_wave_id: {
9878+
MVT VT = MVT::i32;
9879+
auto UpperBound = DAG.getAnyExtOrTrunc(Op.getOperand(0), DL, VT);
9880+
9881+
SIMachineFunctionInfo *MFI = MF.getInfo<SIMachineFunctionInfo>();
9882+
unsigned MaxID = Subtarget->getMaxWorkitemID(MF.getFunction(), 0);
9883+
const ArgDescriptor Arg = MFI->getArgInfo().WorkItemIDX;
9884+
SDValue Val = loadInputValue(DAG, &AMDGPU::SGPR_32RegClass, MVT::i32,
9885+
SDLoc(DAG.getEntryNode()), Arg);
9886+
SDValue Bounded = DAG.getNode(ISD::AND, DL, VT, Val, UpperBound);
9887+
SDValue WaveFrontSize = DAG.getConstant(MF.getSubtarget<GCNSubtarget>().getWavefrontSize(),
9888+
SDLoc(Op), MVT::i32);
9889+
return DAG.getNode(ISD::SDIV, DL, VT, Bounded, WaveFrontSize);
9890+
}
98779891
case Intrinsic::amdgcn_lds_kernel_id: {
98789892
if (MFI->isEntryFunction())
98799893
return getLDSKernelId(DAG, DL);

0 commit comments

Comments
 (0)