[llvm] a3d5ec5 - [AMDGPU][Global-ISel] reuse extension related patterns in td file
Chen Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 9 19:12:35 PDT 2023
Author: Chen Zheng
Date: 2023-04-10T02:11:33Z
New Revision: a3d5ec51bacfadb560cc78a7e866b118027a414e
URL: https://github.com/llvm/llvm-project/commit/a3d5ec51bacfadb560cc78a7e866b118027a414e
DIFF: https://github.com/llvm/llvm-project/commit/a3d5ec51bacfadb560cc78a7e866b118027a414e.diff
LOG: [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 #61468
Reviewed By: arsenm
Differential Revision: https://reviews.llvm.org/D147780
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/AMDGPU/SIInstructions.td
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
index 9904f05714665..6053020e38c48 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
@@ -3417,7 +3417,11 @@ bool AMDGPUInstructionSelector::select(MachineInstr &I) {
case TargetOpcode::G_ZEXT:
case TargetOpcode::G_ANYEXT:
case TargetOpcode::G_SEXT_INREG:
- if (selectImpl(I, *CoverageInfo))
+ // This is a workaround. For extension from type i1, `selectImpl()` uses
+ // patterns from TD file and generates an illegal VGPR to SGPR COPY as type
+ // i1 can only be hold in a SGPR class.
+ if (MRI->getType(I.getOperand(1).getReg()) != LLT::scalar(1) &&
+ selectImpl(I, *CoverageInfo))
return true;
return selectG_SZA_EXT(I);
case TargetOpcode::G_BRCOND:
diff --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index 40adc6178c214..0a33c9b9360f6 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -2020,13 +2020,13 @@ def : GCNPat <
def : GCNPat <
(i32 (sext i1:$src0)),
(V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
- /*src1mod*/(i32 0), /*src1*/(i32 -1), $src0)
+ /*src1mod*/(i32 0), /*src1*/(i32 -1), i1:$src0)
>;
class Ext32Pat <SDNode ext> : GCNPat <
(i32 (ext i1:$src0)),
(V_CNDMASK_B32_e64 /*src0mod*/(i32 0), /*src0*/(i32 0),
- /*src1mod*/(i32 0), /*src1*/(i32 1), $src0)
+ /*src1mod*/(i32 0), /*src1*/(i32 1), i1:$src0)
>;
def : Ext32Pat <zext>;
More information about the llvm-commits
mailing list