[llvm] [SPIR-V] Fix legalize info for G_BITREVERSE (PR #93699)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 08:29:36 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Vyacheslav Levytskyy (VyacheslavLevytskyy)
<details>
<summary>Changes</summary>
This PR fixes legalize info for G_BITREVERSE.
---
Full diff: https://github.com/llvm/llvm-project/pull/93699.diff
2 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVLegalizerInfo.cpp (+1-1)
- (modified) llvm/lib/Target/SPIRV/SPIRVPreLegalizer.cpp (+5)
``````````diff
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);
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)
``````````
</details>
https://github.com/llvm/llvm-project/pull/93699
More information about the llvm-commits
mailing list