Skip to content

Commit 123b0e2

Browse files
authored
Reapply "[AMDGPU][GlobalISel] Properly handle lane op lowering for larger vector types (#132358)" (#135758)
reapply #132358, tests updated.
1 parent 40460a5 commit 123b0e2

File tree

6 files changed

+2750
-34
lines changed

6 files changed

+2750
-34
lines changed

llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5580,6 +5580,7 @@ bool AMDGPULegalizerInfo::legalizeLaneOp(LegalizerHelper &Helper,
55805580
return false;
55815581

55825582
LLT PartialResTy = LLT::scalar(SplitSize);
5583+
bool NeedsBitcast = false;
55835584
if (Ty.isVector()) {
55845585
LLT EltTy = Ty.getElementType();
55855586
unsigned EltSize = EltTy.getSizeInBits();
@@ -5588,8 +5589,10 @@ bool AMDGPULegalizerInfo::legalizeLaneOp(LegalizerHelper &Helper,
55885589
} else if (EltSize == 16 || EltSize == 32) {
55895590
unsigned NElem = SplitSize / EltSize;
55905591
PartialResTy = Ty.changeElementCount(ElementCount::getFixed(NElem));
5592+
} else {
5593+
// Handle all other cases via S32/S64 pieces
5594+
NeedsBitcast = true;
55915595
}
5592-
// Handle all other cases via S32/S64 pieces;
55935596
}
55945597

55955598
SmallVector<Register, 4> PartialRes;
@@ -5615,7 +5618,12 @@ bool AMDGPULegalizerInfo::legalizeLaneOp(LegalizerHelper &Helper,
56155618
PartialRes.push_back(createLaneOp(Src0, Src1, Src2, PartialResTy));
56165619
}
56175620

5618-
B.buildMergeLikeInstr(DstReg, PartialRes);
5621+
if (NeedsBitcast)
5622+
B.buildBitcast(DstReg, B.buildMergeLikeInstr(
5623+
LLT::scalar(Ty.getSizeInBits()), PartialRes));
5624+
else
5625+
B.buildMergeLikeInstr(DstReg, PartialRes);
5626+
56195627
MI.eraseFromParent();
56205628
return true;
56215629
}

0 commit comments

Comments
 (0)