Skip to content

Commit a3d5ec5

Browse files
author
Chen Zheng
committed
[AMDGPU][Global-ISel] reuse extension related patterns in td file
However the imported rules can not be used for now because Global ISel selectImpl() seems has some bug/limitation to create a illegl COPY from VGPR to SGPR. So currently workaround this by not auto selecting these patterns. Fixes llvm#61468 Reviewed By: arsenm Differential Revision: https://reviews.llvm.org/D147780
1 parent 08cf536 commit a3d5ec5

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -3417,7 +3417,11 @@ bool AMDGPUInstructionSelector::select(MachineInstr &I) {
34173417
case TargetOpcode::G_ZEXT:
34183418
case TargetOpcode::G_ANYEXT:
34193419
case TargetOpcode::G_SEXT_INREG:
3420-
if (selectImpl(I, *CoverageInfo))
3420+
// This is a workaround. For extension from type i1, `selectImpl()` uses
3421+
// patterns from TD file and generates an illegal VGPR to SGPR COPY as type
3422+
// i1 can only be hold in a SGPR class.
3423+
if (MRI->getType(I.getOperand(1).getReg()) != LLT::scalar(1) &&
3424+
selectImpl(I, *CoverageInfo))
34213425
return true;
34223426
return selectG_SZA_EXT(I);
34233427
case TargetOpcode::G_BRCOND:

llvm/lib/Target/AMDGPU/SIInstructions.td

+2-2
Original file line numberDiff line numberDiff line change
@@ -2020,13 +2020,13 @@ def : GCNPat <
20202020
def : GCNPat <
20212021
(i32 (sext i1:$src0)),
20222022
(V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
2023-
/*src1mod*/(i32 0), /*src1*/(i32 -1), $src0)
2023+
/*src1mod*/(i32 0), /*src1*/(i32 -1), i1:$src0)
20242024
>;
20252025

20262026
class Ext32Pat <SDNode ext> : GCNPat <
20272027
(i32 (ext i1:$src0)),
20282028
(V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
2029-
/*src1mod*/(i32 0), /*src1*/(i32 1), $src0)
2029+
/*src1mod*/(i32 0), /*src1*/(i32 1), i1:$src0)
20302030
>;
20312031

20322032
def : Ext32Pat <zext>;

0 commit comments

Comments
 (0)