Skip to content

Commit c5b3c8e

Browse files
authored
Add SPIR-V 1.4 checks (#1177)
Signed-off-by: Dmitry Sidorov <[email protected]>
1 parent 4ccb1b2 commit c5b3c8e

File tree

12 files changed

+159
-113
lines changed

12 files changed

+159
-113
lines changed

lib/SPIRV/SPIRVWriter.cpp

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,9 +1181,13 @@ LLVMToSPIRVBase::getLoopControl(const BranchInst *Branch,
11811181
// PartialCount must not be used with the DontUnroll bit
11821182
else if (S == "llvm.loop.unroll.count" &&
11831183
!(LoopControl & LoopControlDontUnrollMask)) {
1184-
size_t I = getMDOperandAsInt(Node, 1);
1185-
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1186-
LoopControl |= spv::LoopControlPartialCountMask;
1184+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
1185+
BM->setMinSPIRVVersion(
1186+
static_cast<SPIRVWord>(VersionNumber::SPIRV_1_4));
1187+
size_t I = getMDOperandAsInt(Node, 1);
1188+
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1189+
LoopControl |= spv::LoopControlPartialCountMask;
1190+
}
11871191
} else if (S == "llvm.loop.ivdep.enable")
11881192
LoopControl |= spv::LoopControlDependencyInfiniteMask;
11891193
else if (S == "llvm.loop.ivdep.safelen") {
@@ -1978,10 +1982,10 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
19781982

19791983
if (auto BVO = dyn_cast_or_null<OverflowingBinaryOperator>(V)) {
19801984
if (BVO->hasNoSignedWrap()) {
1981-
BV->setNoSignedWrap(true);
1985+
BV->setNoIntegerDecorationWrap<DecorationNoSignedWrap>(true);
19821986
}
19831987
if (BVO->hasNoUnsignedWrap()) {
1984-
BV->setNoUnsignedWrap(true);
1988+
BV->setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(true);
19851989
}
19861990
}
19871991

@@ -3795,6 +3799,12 @@ bool LLVMToSPIRVBase::transExecutionMode() {
37953799
if (!BF)
37963800
return false;
37973801

3802+
auto AddSingleArgExecutionMode = [&](ExecutionMode EMode) {
3803+
uint32_t Arg;
3804+
N.get(Arg);
3805+
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(BF, EMode, Arg)));
3806+
};
3807+
37983808
switch (EMode) {
37993809
case spv::ExecutionModeContractionOff:
38003810
BF->addExecutionMode(BM->add(
@@ -3829,53 +3839,47 @@ bool LLVMToSPIRVBase::transExecutionMode() {
38293839
}
38303840
} break;
38313841
case spv::ExecutionModeNoGlobalOffsetINTEL: {
3832-
if (BM->isAllowedToUseExtension(
3833-
ExtensionID::SPV_INTEL_kernel_attributes)) {
3834-
BF->addExecutionMode(BM->add(
3835-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
3836-
BM->addCapability(CapabilityKernelAttributesINTEL);
3837-
}
3842+
if (!BM->isAllowedToUseExtension(
3843+
ExtensionID::SPV_INTEL_kernel_attributes))
3844+
break;
3845+
BF->addExecutionMode(BM->add(
3846+
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
3847+
BM->addCapability(CapabilityKernelAttributesINTEL);
38383848
} break;
38393849
case spv::ExecutionModeVecTypeHint:
38403850
case spv::ExecutionModeSubgroupSize:
3841-
case spv::ExecutionModeSubgroupsPerWorkgroup: {
3842-
unsigned X;
3843-
N.get(X);
3844-
BF->addExecutionMode(BM->add(
3845-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode), X)));
3846-
} break;
3851+
case spv::ExecutionModeSubgroupsPerWorkgroup:
3852+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
3853+
break;
38473854
case spv::ExecutionModeNumSIMDWorkitemsINTEL:
38483855
case spv::ExecutionModeSchedulerTargetFmaxMhzINTEL:
38493856
case spv::ExecutionModeMaxWorkDimINTEL: {
3850-
if (BM->isAllowedToUseExtension(
3851-
ExtensionID::SPV_INTEL_kernel_attributes)) {
3852-
unsigned X;
3853-
N.get(X);
3854-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
3855-
BF, static_cast<ExecutionMode>(EMode), X)));
3856-
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
3857-
}
3857+
if (!BM->isAllowedToUseExtension(
3858+
ExtensionID::SPV_INTEL_kernel_attributes))
3859+
break;
3860+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
3861+
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
38583862
} break;
38593863
case spv::ExecutionModeSharedLocalMemorySizeINTEL: {
38603864
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
38613865
break;
3862-
unsigned SLMSize;
3863-
N.get(SLMSize);
3864-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
3865-
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
3866+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
38663867
} break;
38673868

38683869
case spv::ExecutionModeDenormPreserve:
38693870
case spv::ExecutionModeDenormFlushToZero:
38703871
case spv::ExecutionModeSignedZeroInfNanPreserve:
38713872
case spv::ExecutionModeRoundingModeRTE:
38723873
case spv::ExecutionModeRoundingModeRTZ: {
3873-
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_float_controls))
3874-
break;
3875-
unsigned TargetWidth;
3876-
N.get(TargetWidth);
3877-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
3878-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
3874+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
3875+
BM->setMinSPIRVVersion(
3876+
static_cast<SPIRVWord>(VersionNumber::SPIRV_1_4));
3877+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
3878+
} else if (BM->isAllowedToUseExtension(
3879+
ExtensionID::SPV_KHR_float_controls)) {
3880+
BM->addExtension(ExtensionID::SPV_KHR_float_controls);
3881+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
3882+
}
38793883
} break;
38803884
case spv::ExecutionModeRoundingModeRTPINTEL:
38813885
case spv::ExecutionModeRoundingModeRTNINTEL:
@@ -3884,10 +3888,7 @@ bool LLVMToSPIRVBase::transExecutionMode() {
38843888
if (!BM->isAllowedToUseExtension(
38853889
ExtensionID::SPV_INTEL_float_controls2))
38863890
break;
3887-
unsigned TargetWidth;
3888-
N.get(TargetWidth);
3889-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
3890-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
3891+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
38913892
} break;
38923893
case spv::internal::ExecutionModeFastCompositeKernelINTEL: {
38933894
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite))

lib/SPIRV/libSPIRV/SPIRVDecorate.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ class SPIRVDecorateGeneric : public SPIRVAnnotationGeneric {
103103

104104
case DecorationMaxByteOffset:
105105
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_1);
106+
case DecorationUserSemantic:
107+
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_4);
106108

107109
default:
108110
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_0);
@@ -155,9 +157,6 @@ class SPIRVDecorate : public SPIRVDecorateGeneric {
155157

156158
llvm::Optional<ExtensionID> getRequiredExtension() const override {
157159
switch (static_cast<size_t>(Dec)) {
158-
case DecorationNoSignedWrap:
159-
case DecorationNoUnsignedWrap:
160-
return ExtensionID::SPV_KHR_no_integer_wrap_decoration;
161160
case DecorationRegisterINTEL:
162161
case DecorationMemoryINTEL:
163162
case DecorationNumbanksINTEL:

lib/SPIRV/libSPIRV/SPIRVEntry.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -841,12 +841,6 @@ class SPIRVCapability : public SPIRVEntryNoId<OpCapability> {
841841

842842
llvm::Optional<ExtensionID> getRequiredExtension() const override {
843843
switch (static_cast<unsigned>(Kind)) {
844-
case CapabilityDenormPreserve:
845-
case CapabilityDenormFlushToZero:
846-
case CapabilitySignedZeroInfNanPreserve:
847-
case CapabilityRoundingModeRTE:
848-
case CapabilityRoundingModeRTZ:
849-
return ExtensionID::SPV_KHR_float_controls;
850844
case CapabilityRoundToInfinityINTEL:
851845
case CapabilityFloatingPointModeINTEL:
852846
case CapabilityFunctionFloatControlINTEL:

lib/SPIRV/libSPIRV/SPIRVValue.cpp

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -75,45 +75,10 @@ bool SPIRVValue::hasNoSignedWrap() const {
7575
return hasDecorate(DecorationNoSignedWrap);
7676
}
7777

78-
void SPIRVValue::setNoSignedWrap(bool HasNoSignedWrap) {
79-
if (!HasNoSignedWrap) {
80-
eraseDecorate(DecorationNoSignedWrap);
81-
}
82-
if (Module->isAllowedToUseExtension(
83-
ExtensionID::SPV_KHR_no_integer_wrap_decoration)) {
84-
// NoSignedWrap decoration is available only if it is allowed to use SPIR-V
85-
// 1.4 or if SPV_KHR_no_integer_wrap_decoration extension is allowed
86-
// FIXME: update this 'if' to include check for SPIR-V 1.4 once translator
87-
// support this version
88-
addDecorate(new SPIRVDecorate(DecorationNoSignedWrap, this));
89-
SPIRVDBG(spvdbgs() << "Set nsw for obj " << Id << "\n")
90-
} else {
91-
SPIRVDBG(spvdbgs() << "Skip setting nsw for obj " << Id << "\n")
92-
}
93-
}
94-
9578
bool SPIRVValue::hasNoUnsignedWrap() const {
9679
return hasDecorate(DecorationNoUnsignedWrap);
9780
}
9881

99-
void SPIRVValue::setNoUnsignedWrap(bool HasNoUnsignedWrap) {
100-
if (!HasNoUnsignedWrap) {
101-
eraseDecorate(DecorationNoUnsignedWrap);
102-
return;
103-
}
104-
if (Module->isAllowedToUseExtension(
105-
ExtensionID::SPV_KHR_no_integer_wrap_decoration)) {
106-
// NoUnsignedWrap decoration is available only if it is allowed to use
107-
// SPIR-V 1.4 or if SPV_KHR_no_integer_wrap_decoration extension is allowed
108-
// FIXME: update this 'if' to include check for SPIR-V 1.4 once translator
109-
// support this version
110-
addDecorate(new SPIRVDecorate(DecorationNoUnsignedWrap, this));
111-
SPIRVDBG(spvdbgs() << "Set nuw for obj " << Id << "\n")
112-
} else {
113-
SPIRVDBG(spvdbgs() << "Skip setting nuw for obj " << Id << "\n")
114-
}
115-
}
116-
11782
void SPIRVValue::setFPFastMathMode(SPIRVWord M) {
11883
if (M == 0) {
11984
eraseDecorate(DecorationFPFastMathMode);
@@ -124,6 +89,40 @@ void SPIRVValue::setFPFastMathMode(SPIRVWord M) {
12489
<< "\n")
12590
}
12691

92+
template <spv::Decoration NoIntegerWrapDecoration>
93+
void SPIRVValue::setNoIntegerDecorationWrap(bool HasNoIntegerWrap) {
94+
if (!HasNoIntegerWrap) {
95+
eraseDecorate(NoIntegerWrapDecoration);
96+
return;
97+
}
98+
// NoSignedWrap and NoUnsignedWrap decorations are available only if it is
99+
// allowed to use SPIR-V 1.4 or if SPV_KHR_no_integer_wrap_decoration
100+
// extension is enabled
101+
#ifdef _SPIRVDBG
102+
const std::string InstStr =
103+
NoIntegerWrapDecoration == DecorationNoSignedWrap ? "nsw" : "nuw";
104+
#endif // _SPIRVDBG
105+
if (Module->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
106+
Module->setMinSPIRVVersion(
107+
static_cast<SPIRVWord>(VersionNumber::SPIRV_1_4));
108+
addDecorate(new SPIRVDecorate(NoIntegerWrapDecoration, this));
109+
SPIRVDBG(spvdbgs() << "Set " << InstStr << " for obj " << Id << "\n")
110+
} else if (Module->isAllowedToUseExtension(
111+
ExtensionID::SPV_KHR_no_integer_wrap_decoration)) {
112+
Module->addExtension(ExtensionID::SPV_KHR_no_integer_wrap_decoration);
113+
addDecorate(new SPIRVDecorate(NoIntegerWrapDecoration, this));
114+
SPIRVDBG(spvdbgs() << "Set " << InstStr << " for obj " << Id << "\n")
115+
} else {
116+
SPIRVDBG(spvdbgs() << "Skip setting " << InstStr << " for obj " << Id
117+
<< "\n")
118+
}
119+
}
120+
121+
template void
122+
SPIRVValue::setNoIntegerDecorationWrap<DecorationNoSignedWrap>(bool);
123+
template void
124+
SPIRVValue::setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(bool);
125+
127126
template <spv::Op OC>
128127
void SPIRVConstantBase<OC>::setWords(const uint64_t *TheValue) {
129128
assert(TheValue && "Nullptr value");

lib/SPIRV/libSPIRV/SPIRVValue.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,10 @@ class SPIRVValue : public SPIRVEntry {
9898

9999
void setAlignment(SPIRVWord);
100100
void setVolatile(bool IsVolatile);
101-
void setNoSignedWrap(bool HasNoSignedWrap);
102-
void setNoUnsignedWrap(bool HasNoUnsignedWrap);
101+
102+
template <spv::Decoration NoIntegerWrapDecoration>
103+
void setNoIntegerDecorationWrap(bool HasNoIntegerWrap);
104+
103105
void setFPFastMathMode(SPIRVWord FPFastMathMode);
104106

105107
void validate() const override {

test/exec_mode_float_control_khr.ll

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_KHR_float_controls
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.1 --spirv-ext=+SPV_KHR_float_controls
33
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
4-
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
4+
; RUN: FileCheck %s --input-file %t.spt -check-prefixes=SPV,SPVEXT
5+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.4
6+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
7+
; RUN: FileCheck %s --input-file %t.spt -check-prefixes=SPV,SPV14
8+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.1
9+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
10+
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV-NEGATIVE
511

612
; ModuleID = 'float_control.bc'
713
source_filename = "float_control.cpp"
@@ -44,6 +50,10 @@ entry:
4450
!spirv.EntryPoint = !{}
4551
!spirv.ExecutionMode = !{!15, !16, !17, !18, !19, !20, !21, !22, !23, !24, !25, !26, !27, !28, !29}
4652

53+
; SPVEXT-DAG: Extension "SPV_KHR_float_controls"
54+
; SPV14-NOT: Extension "SPV_KHR_float_controls"
55+
; SPV-NEGATIVE-NOT: Extension "SPV_KHR_float_controls"
56+
4757
; SPV-DAG: EntryPoint {{[0-9]+}} [[KERNEL0:[0-9]+]] "k_float_controls_0"
4858
; SPV-DAG: EntryPoint {{[0-9]+}} [[KERNEL1:[0-9]+]] "k_float_controls_1"
4959
; SPV-DAG: EntryPoint {{[0-9]+}} [[KERNEL2:[0-9]+]] "k_float_controls_2"

test/transcoding/LoopUnroll.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@
4242
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
4343
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
4444
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM
45+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.1
46+
; RUN: llvm-spirv -to-text %t.spv -o %t.spt
47+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV-NEGATIVE
48+
49+
; Check SPIR-V versions in a format magic number + version
50+
; CHECK-SPIRV: 119734787 66560
51+
; CHECK-SPIRV-NEGATIVE: 119734787 65536
4552

4653
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
4754
target triple = "spir64"
@@ -115,6 +122,7 @@ while.cond: ; preds = %if.end, %if.then, %
115122
; Per SPIRV spec p3.23 "Unroll" loop control = 0x1
116123
; CHECK-SPIRV: LoopMerge [[#MERGEBLOCK:]] [[#CONTINUE:]] 256 8
117124
; CHECK-SPIRV: BranchConditional [[#]] [[#]] [[#MERGEBLOCK]]
125+
; CHECK-SPIRV-NEGATIVE-NOT: LoopMerge {{.*}} 256
118126
br i1 %cmp, label %while.body, label %while.end
119127

120128
while.body: ; preds = %while.cond

test/transcoding/NoSignedUnsignedWrap.ll

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88
; Positive tests:
99
;
1010
; RUN: llvm-as %s -o %t.bc
11-
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
12-
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.spv
11+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.1 --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT
12+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.1 --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.spv
1313
; RUN: spirv-val %t.spv
14-
; RUN: llvm-spirv -r %t.spv --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.rev.bc
14+
; RUN: llvm-spirv -r %t.spv --spirv-max-version=1.1 --spirv-ext=+SPV_KHR_no_integer_wrap_decoration -o %t.rev.bc
15+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
16+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.4 -spirv-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT
17+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.4 -o %t.spv
18+
; RUN: spirv-val %t.spv
19+
; RUN: llvm-spirv -r %t.spv --spirv-max-version=1.4 -o %t.rev.bc
1520
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
1621
;
1722
; During consumption, any SPIR-V extension must be accepted by default
@@ -21,29 +26,29 @@
2126
;
2227
; Negative tests:
2328
;
24-
; Check that translator is able to reject SPIR-V if extension is disallowed
25-
;
26-
; RUN: not llvm-spirv -r %t.spv --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -o - 2>&1 | FileCheck %s --check-prefix=CHECK-INVALID-SPIRV
27-
;
28-
; Check that translator is able to skip nsw/nuw attributes if extension is disabled implicitly or explicitly
29+
; Check that translator is able to skip nsw/nuw attributes if extension is
30+
; disabled implicitly or explicitly and if max SPIR-V version is lower then 1.4
2931
;
30-
; RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NOEXT
31-
; RUN: llvm-spirv %t.bc -o %t.spv
32+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.1 -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NEGATIVE
33+
; RUN: llvm-spirv --spirv-max-version=1.1 %t.bc -o %t.spv
3234
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
33-
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT
35+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NEGATIVE
3436
;
35-
; RUN: llvm-spirv %t.bc --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NOEXT
36-
; RUN: llvm-spirv %t.bc --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -o %t.spv
37+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.1 --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV-NEGATIVE
38+
; RUN: llvm-spirv %t.bc --spirv-max-version=1.1 --spirv-ext=-SPV_KHR_no_integer_wrap_decoration -o %t.spv
3739
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
38-
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT
40+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NEGATIVE
3941

40-
; CHECK-SPIRV: Extension "SPV_KHR_no_integer_wrap_decoration"
42+
; Check SPIR-V versions in a format magic number + version
43+
; CHECK-SPIRV-EXT: 119734787 65536
44+
; CHECK-SPIRV-EXT: Extension "SPV_KHR_no_integer_wrap_decoration"
45+
; CHECK-SPIRV-NOEXT: 119734787 66560
4146
; CHECK-SPIRV: Decorate {{[0-9]+}} NoSignedWrap
4247
; CHECK-SPIRV: Decorate {{[0-9]+}} NoUnsignedWrap
4348
;
44-
; CHECK-SPIRV-NOEXT-NOT: Extension "SPV_KHR_no_integer_wrap_decoration"
45-
; CHECK-SPIRV-NOEXT-NOT: Decorate {{[0-9]+}} NoSignedWrap
46-
; CHECK-SPIRV-NOEXT-NOT: Decorate {{[0-9]+}} NoUnsignedWrap
49+
; CHECK-SPIRV-NEGATIVE-NOT: Extension "SPV_KHR_no_integer_wrap_decoration"
50+
; CHECK-SPIRV-NEGATIVE-NOT: Decorate {{[0-9]+}} NoSignedWrap
51+
; CHECK-SPIRV-NEGATIVE-NOT: Decorate {{[0-9]+}} NoUnsignedWrap
4752
;
4853
; CHECK-INVALID-SPIRV: input SPIR-V module uses extension 'SPV_KHR_no_integer_wrap_decoration' which were disabled
4954

@@ -55,7 +60,7 @@ define spir_func i32 @square(i16 zeroext %a) local_unnamed_addr #0 {
5560
entry:
5661
%conv = zext i16 %a to i32
5762
; CHECK-LLVM: mul nuw nsw
58-
; CHECK-LLVM-NOEXT: mul i32
63+
; CHECK-LLVM-NEGATIVE: mul i32
5964
%mul = mul nuw nsw i32 %conv, %conv
6065
ret i32 %mul
6166
}

0 commit comments

Comments
 (0)