-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIR-V] Fix legalize info for G_BITREVERSE #93699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SPIR-V] Fix legalize info for G_BITREVERSE #93699
Conversation
@llvm/pr-subscribers-backend-spir-v Author: Vyacheslav Levytskyy (VyacheslavLevytskyy) ChangesThis PR fixes legalize info for G_BITREVERSE. Full diff: https://github.com/llvm/llvm-project/pull/93699.diff 2 Files Affected:
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)
|
Drive by nit: Why were there no test changes, when you touched the legalizer? |
I think HLSL should have a |
It originated from https://reviews.llvm.org/D116464, which is a huge patch with no tests. |
@tschuett Yes, it looks like legalizer wasn't covered by tests properly. It's one of our priorities now to improve test cases. |
@farzonl I don't expect HLSL's |
Failed CI builds are not related to the PR content. |
This PR fixes legalize info for G_BITREVERSE.