-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SPIRV] Stop unconditionally emitting SPV_INTEL_arbitrary_precision_integers when allowed #137167
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
Merged
VyacheslavLevytskyy
merged 1 commit into
llvm:main
from
Naghasan:victor/dont-emit-unused-cap
Apr 28, 2025
Merged
[SPIRV] Stop unconditionally emitting SPV_INTEL_arbitrary_precision_integers when allowed #137167
VyacheslavLevytskyy
merged 1 commit into
llvm:main
from
Naghasan:victor/dont-emit-unused-cap
Apr 28, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ntegers when allowed When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
@llvm/pr-subscribers-backend-spir-v Author: Victor Lomuller (Naghasan) ChangesWhen the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded. Full diff: https://github.com/llvm/llvm-project/pull/137167.diff 2 Files Affected:
diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index 4ce316ea32e1c..31b8ffe4099a7 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -27,6 +27,7 @@
#include "llvm/IR/IntrinsicsSPIRV.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/Casting.h"
+#include "llvm/Support/MathExtras.h"
#include <cassert>
#include <functional>
@@ -175,7 +176,8 @@ SPIRVType *SPIRVGlobalRegistry::getOpTypeInt(unsigned Width,
const SPIRVSubtarget &ST =
cast<SPIRVSubtarget>(MIRBuilder.getMF().getSubtarget());
return createOpType(MIRBuilder, [&](MachineIRBuilder &MIRBuilder) {
- if (ST.canUseExtension(
+ if ((!isPowerOf2_32(Width) || Width < 8) &&
+ ST.canUseExtension(
SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers)) {
MIRBuilder.buildInstr(SPIRV::OpExtension)
.addImm(SPIRV::Extension::SPV_INTEL_arbitrary_precision_integers);
diff --git a/llvm/test/CodeGen/SPIRV/extensions/unused-but-allowed-SPV_INTEL_arbitrary_precision_integers.ll b/llvm/test/CodeGen/SPIRV/extensions/unused-but-allowed-SPV_INTEL_arbitrary_precision_integers.ll
new file mode 100644
index 0000000000000..2c1257471d159
--- /dev/null
+++ b/llvm/test/CodeGen/SPIRV/extensions/unused-but-allowed-SPV_INTEL_arbitrary_precision_integers.ll
@@ -0,0 +1,19 @@
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=+SPV_INTEL_arbitrary_precision_integers %s -o - | FileCheck %s
+
+define i8 @getConstantI8() {
+ ret i8 2
+}
+define i16 @getConstantI16() {
+ ret i16 2
+}
+define i32 @getConstantI32() {
+ ret i32 2
+}
+
+define i64 @getConstantI64() {
+ ret i64 42
+}
+
+;; Capabilities:
+; CHECK-NOT: OpExtension "SPV_INTEL_arbitrary_precision_integers"
+; CHECK-NOT: OpCapability ArbitraryPrecisionIntegersINTEL
|
VyacheslavLevytskyy
approved these changes
Apr 24, 2025
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…ntegers when allowed (llvm#137167) When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…ntegers when allowed (llvm#137167) When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
IanWood1
pushed a commit
to IanWood1/llvm-project
that referenced
this pull request
May 6, 2025
…ntegers when allowed (llvm#137167) When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
GeorgeARM
pushed a commit
to GeorgeARM/llvm-project
that referenced
this pull request
May 7, 2025
…ntegers when allowed (llvm#137167) When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
Ankur-0429
pushed a commit
to Ankur-0429/llvm-project
that referenced
this pull request
May 9, 2025
…ntegers when allowed (llvm#137167) When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions. The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When the SPV_INTEL_arbitrary_precision_integers extension is allowed to be used, the backend will unconditionnally add it to the module used extensions.
The patch prevent SPV_INTEL_arbitrary_precision_integers from being declared if unneeded.