Skip to content

Commit fc8d38e

Browse files
committed
Cherry-pick of "Add SPIR-V 1.4 checks"
Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
1 parent 9f89247 commit fc8d38e

File tree

12 files changed

+168
-137
lines changed

12 files changed

+168
-137
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,9 +1413,12 @@ LLVMToSPIRVBase::getLoopControl(const BranchInst *Branch,
14131413
// PartialCount must not be used with the DontUnroll bit
14141414
else if (S == "llvm.loop.unroll.count" &&
14151415
!(LoopControl & LoopControlDontUnrollMask)) {
1416-
size_t I = getMDOperandAsInt(Node, 1);
1417-
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1418-
LoopControl |= spv::LoopControlPartialCountMask;
1416+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
1417+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
1418+
size_t I = getMDOperandAsInt(Node, 1);
1419+
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1420+
LoopControl |= spv::LoopControlPartialCountMask;
1421+
}
14191422
} else if (S == "llvm.loop.ivdep.enable")
14201423
LoopControl |= spv::LoopControlDependencyInfiniteMask;
14211424
else if (S == "llvm.loop.ivdep.safelen") {
@@ -2476,10 +2479,10 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
24762479

24772480
if (auto BVO = dyn_cast_or_null<OverflowingBinaryOperator>(V)) {
24782481
if (BVO->hasNoSignedWrap()) {
2479-
BV->setNoSignedWrap(true);
2482+
BV->setNoIntegerDecorationWrap<DecorationNoSignedWrap>(true);
24802483
}
24812484
if (BVO->hasNoUnsignedWrap()) {
2482-
BV->setNoUnsignedWrap(true);
2485+
BV->setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(true);
24832486
}
24842487
}
24852488

@@ -4605,43 +4608,34 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46054608
}
46064609
} break;
46074610
case spv::ExecutionModeNoGlobalOffsetINTEL: {
4608-
if (BM->isAllowedToUseExtension(
4609-
ExtensionID::SPV_INTEL_kernel_attributes)) {
4610-
BF->addExecutionMode(BM->add(
4611-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4612-
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4613-
BM->addCapability(CapabilityKernelAttributesINTEL);
4614-
}
4611+
if (!BM->isAllowedToUseExtension(
4612+
ExtensionID::SPV_INTEL_kernel_attributes))
4613+
break;
4614+
BF->addExecutionMode(BM->add(
4615+
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4616+
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4617+
BM->addCapability(CapabilityKernelAttributesINTEL);
46154618
} break;
46164619
case spv::ExecutionModeVecTypeHint:
46174620
case spv::ExecutionModeSubgroupSize:
4618-
case spv::ExecutionModeSubgroupsPerWorkgroup: {
4619-
unsigned X;
4620-
N.get(X);
4621-
BF->addExecutionMode(BM->add(
4622-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode), X)));
4623-
} break;
4621+
case spv::ExecutionModeSubgroupsPerWorkgroup:
4622+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4623+
break;
46244624
case spv::ExecutionModeNumSIMDWorkitemsINTEL:
46254625
case spv::ExecutionModeSchedulerTargetFmaxMhzINTEL:
46264626
case spv::ExecutionModeMaxWorkDimINTEL:
46274627
case spv::internal::ExecutionModeStreamingInterfaceINTEL: {
4628-
if (BM->isAllowedToUseExtension(
4629-
ExtensionID::SPV_INTEL_kernel_attributes)) {
4630-
unsigned X;
4631-
N.get(X);
4632-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4633-
BF, static_cast<ExecutionMode>(EMode), X)));
4634-
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4635-
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
4636-
}
4628+
if (!BM->isAllowedToUseExtension(
4629+
ExtensionID::SPV_INTEL_kernel_attributes))
4630+
break;
4631+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4632+
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4633+
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
46374634
} break;
46384635
case spv::ExecutionModeSharedLocalMemorySizeINTEL: {
46394636
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
46404637
break;
4641-
unsigned SLMSize;
4642-
N.get(SLMSize);
4643-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4644-
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
4638+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
46454639
} break;
46464640
case spv::ExecutionModeNamedBarrierCountINTEL: {
46474641
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
@@ -4659,12 +4653,14 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46594653
case spv::ExecutionModeSignedZeroInfNanPreserve:
46604654
case spv::ExecutionModeRoundingModeRTE:
46614655
case spv::ExecutionModeRoundingModeRTZ: {
4662-
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_float_controls))
4663-
break;
4664-
unsigned TargetWidth;
4665-
N.get(TargetWidth);
4666-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4667-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
4656+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
4657+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
4658+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4659+
} else if (BM->isAllowedToUseExtension(
4660+
ExtensionID::SPV_KHR_float_controls)) {
4661+
BM->addExtension(ExtensionID::SPV_KHR_float_controls);
4662+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4663+
}
46684664
} break;
46694665
case spv::ExecutionModeRoundingModeRTPINTEL:
46704666
case spv::ExecutionModeRoundingModeRTNINTEL:
@@ -4673,10 +4669,7 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46734669
if (!BM->isAllowedToUseExtension(
46744670
ExtensionID::SPV_INTEL_float_controls2))
46754671
break;
4676-
unsigned TargetWidth;
4677-
N.get(TargetWidth);
4678-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4679-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
4672+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
46804673
} break;
46814674
case spv::internal::ExecutionModeFastCompositeKernelINTEL: {
46824675
if (BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_fast_composite))

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVDecorate.h

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

9595
case DecorationMaxByteOffset:
9696
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_1);
97+
case DecorationUserSemantic:
98+
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_4);
9799

98100
default:
99101
return static_cast<SPIRVWord>(VersionNumber::SPIRV_1_0);
@@ -127,9 +129,6 @@ class SPIRVDecorate : public SPIRVDecorateGeneric {
127129

128130
llvm::Optional<ExtensionID> getRequiredExtension() const override {
129131
switch (static_cast<size_t>(Dec)) {
130-
case DecorationNoSignedWrap:
131-
case DecorationNoUnsignedWrap:
132-
return ExtensionID::SPV_KHR_no_integer_wrap_decoration;
133132
case DecorationRegisterINTEL:
134133
case DecorationMemoryINTEL:
135134
case DecorationNumbanksINTEL:

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVEntry.h

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

844844
llvm::Optional<ExtensionID> getRequiredExtension() const override {
845845
switch (static_cast<unsigned>(Kind)) {
846-
case CapabilityDenormPreserve:
847-
case CapabilityDenormFlushToZero:
848-
case CapabilitySignedZeroInfNanPreserve:
849-
case CapabilityRoundingModeRTE:
850-
case CapabilityRoundingModeRTZ:
851-
return ExtensionID::SPV_KHR_float_controls;
852846
case CapabilityRoundToInfinityINTEL:
853847
case CapabilityFloatingPointModeINTEL:
854848
case CapabilityFunctionFloatControlINTEL:

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVValue.cpp

Lines changed: 33 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,39 @@ 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(VersionNumber::SPIRV_1_4);
107+
addDecorate(new SPIRVDecorate(NoIntegerWrapDecoration, this));
108+
SPIRVDBG(spvdbgs() << "Set " << InstStr << " for obj " << Id << "\n")
109+
} else if (Module->isAllowedToUseExtension(
110+
ExtensionID::SPV_KHR_no_integer_wrap_decoration)) {
111+
Module->addExtension(ExtensionID::SPV_KHR_no_integer_wrap_decoration);
112+
addDecorate(new SPIRVDecorate(NoIntegerWrapDecoration, this));
113+
SPIRVDBG(spvdbgs() << "Set " << InstStr << " for obj " << Id << "\n")
114+
} else {
115+
SPIRVDBG(spvdbgs() << "Skip setting " << InstStr << " for obj " << Id
116+
<< "\n")
117+
}
118+
}
119+
120+
template void
121+
SPIRVValue::setNoIntegerDecorationWrap<DecorationNoSignedWrap>(bool);
122+
template void
123+
SPIRVValue::setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(bool);
124+
127125
template <spv::Op OC>
128126
void SPIRVConstantBase<OC>::setWords(const uint64_t *TheValue) {
129127
assert(TheValue && "Nullptr value");

llvm-spirv/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 {

llvm-spirv/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"

llvm-spirv/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 -emit-opaque-pointers %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

llvm-spirv/test/transcoding/NoSignedUnsignedWrap.ll

Lines changed: 26 additions & 21 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 -emit-opaque-pointers %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 -emit-opaque-pointers %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
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
2731
;
28-
; Check that translator is able to skip nsw/nuw attributes if extension is disabled implicitly or explicitly
29-
;
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 -r %t.spv -o %t.rev.bc
33-
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT
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
34+
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
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 -r %t.spv -o %t.rev.bc
38-
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM-NOEXT
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
39+
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
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-DAG: Decorate {{[0-9]+}} NoSignedWrap
4247
; CHECK-SPIRV-DAG: 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)