[llvm] [SPIR-V] Fix legalize info for G_BITREVERSE (PR #93699)
Vyacheslav Levytskyy via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 08:29:07 PDT 2024
https://github.com/VyacheslavLevytskyy created https://github.com/llvm/llvm-project/pull/93699
This PR fixes legalize info for G_BITREVERSE.
>From c7ed9e84c4a67c480835535153c50a1fdb5735ed Mon Sep 17 00:00:00 2001
From: "Levytskyy, Vyacheslav" <vyacheslav.levytskyy at intel.com>
Date: Wed, 29 May 2024 05:05:29 -0700
Subject: [PATCH 1/2] fix legalizer info for G_BITREVERSE
---
llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp b/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
index 42d36fd30ed6f..57fbf3b3f8f12 100644
--- a/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp
@@ -182,7 +182,7 @@ SPIRVLegalizerInfo::SPIRVLegalizerInfo(const SPIRVSubtarget &ST) {
getActionDefinitionsBuilder({G_LOAD, G_STORE}).legalIf(typeInSet(1, allPtrs));
- getActionDefinitionsBuilder(G_BITREVERSE).legalFor(allFloatScalarsAndVectors);
+ getActionDefinitionsBuilder(G_BITREVERSE).legalFor(allIntScalarsAndVectors);
getActionDefinitionsBuilder(G_FMA).legalFor(allFloatScalarsAndVectors);
>From 34a1e4eb66103c5679d4dbaf170ebff3b41a439b Mon Sep 17 00:00:00 2001
From: "Levytskyy, Vyacheslav" <vyacheslav.levytskyy at intel.com>
Date: Wed, 29 May 2024 08:27:19 -0700
Subject: [PATCH 2/2] adjust register type
---
llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
index 624899600693a..3d536085b78aa 100644
--- a/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp
@@ -472,6 +472,11 @@ generateAssignInstrs(MachineFunction &MF, SPIRVGlobalRegistry *GR,
insertAssignInstr(Reg, Ty, nullptr, GR, MIB, MRI);
} else if (MIOp == TargetOpcode::G_GLOBAL_VALUE) {
propagateSPIRVType(&MI, GR, MRI, MIB);
+ } else if (MIOp == TargetOpcode::G_BITREVERSE) {
+ Register Reg = MI.getOperand(0).getReg();
+ LLT RegType = MRI.getType(Reg);
+ if (RegType.getSizeInBits() < 32)
+ MRI.setType(Reg, LLT::scalar(32));
}
if (MII == Begin)
More information about the llvm-commits
mailing list