Skip to content

Commit acdc503

Browse files
committed
[AMDGPU][GlobalISel] Update applyMappingImpl for G_ABS and type v2s16
For G_ABS with type v2s16 and sgpr inputs break down into two s32 G_ABS instructions. Patch by: Acim Maravic Differential Revision: https://reviews.llvm.org/D155867
1 parent fadf3e7 commit acdc503

File tree

3 files changed

+477
-0
lines changed

3 files changed

+477
-0
lines changed

llvm/lib/Target/AMDGPU/AMDGPURegisterBankInfo.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2404,6 +2404,18 @@ void AMDGPURegisterBankInfo::applyMappingImpl(
24042404
MachineFunction *MF = MBB->getParent();
24052405
ApplyRegBankMapping ApplySALU(B, *this, MRI, &AMDGPU::SGPRRegBank);
24062406

2407+
if (DstTy.isVector() && Opc == AMDGPU::G_ABS) {
2408+
Register WideSrcLo, WideSrcHi;
2409+
2410+
std::tie(WideSrcLo, WideSrcHi) =
2411+
unpackV2S16ToS32(B, MI.getOperand(1).getReg(), TargetOpcode::G_SEXT);
2412+
auto Lo = B.buildInstr(AMDGPU::G_ABS, {S32}, {WideSrcLo});
2413+
auto Hi = B.buildInstr(AMDGPU::G_ABS, {S32}, {WideSrcHi});
2414+
B.buildBuildVectorTrunc(DstReg, {Lo.getReg(0), Hi.getReg(0)});
2415+
MI.eraseFromParent();
2416+
return;
2417+
}
2418+
24072419
if (DstTy.isVector()) {
24082420
Register WideSrc0Lo, WideSrc0Hi;
24092421
Register WideSrc1Lo, WideSrc1Hi;

0 commit comments

Comments
 (0)