Skip to content

Commit be0905f

Browse files
authored
Cherry-pick of "Add SPIR-V 1.4 checks" (#6899)
One of the patches missing in intel/llvm Original commit: KhronosGroup/SPIRV-LLVM-Translator@c5b3c8e3283b Signed-off-by: Sidorov, Dmitry <dmitry.sidorov@intel.com>
1 parent 4189858 commit be0905f

File tree

12 files changed

+165
-136
lines changed

12 files changed

+165
-136
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,9 +1418,12 @@ LLVMToSPIRVBase::getLoopControl(const BranchInst *Branch,
14181418
// PartialCount must not be used with the DontUnroll bit
14191419
else if (S == "llvm.loop.unroll.count" &&
14201420
!(LoopControl & LoopControlDontUnrollMask)) {
1421-
size_t I = getMDOperandAsInt(Node, 1);
1422-
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1423-
LoopControl |= spv::LoopControlPartialCountMask;
1421+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
1422+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
1423+
size_t I = getMDOperandAsInt(Node, 1);
1424+
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1425+
LoopControl |= spv::LoopControlPartialCountMask;
1426+
}
14241427
} else if (S == "llvm.loop.ivdep.enable")
14251428
LoopControl |= spv::LoopControlDependencyInfiniteMask;
14261429
else if (S == "llvm.loop.ivdep.safelen") {
@@ -2481,10 +2484,10 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
24812484

24822485
if (auto BVO = dyn_cast_or_null<OverflowingBinaryOperator>(V)) {
24832486
if (BVO->hasNoSignedWrap()) {
2484-
BV->setNoSignedWrap(true);
2487+
BV->setNoIntegerDecorationWrap<DecorationNoSignedWrap>(true);
24852488
}
24862489
if (BVO->hasNoUnsignedWrap()) {
2487-
BV->setNoUnsignedWrap(true);
2490+
BV->setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(true);
24882491
}
24892492
}
24902493

@@ -4610,43 +4613,34 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46104613
}
46114614
} break;
46124615
case spv::ExecutionModeNoGlobalOffsetINTEL: {
4613-
if (BM->isAllowedToUseExtension(
4614-
ExtensionID::SPV_INTEL_kernel_attributes)) {
4615-
BF->addExecutionMode(BM->add(
4616-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4617-
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4618-
BM->addCapability(CapabilityKernelAttributesINTEL);
4619-
}
4616+
if (!BM->isAllowedToUseExtension(
4617+
ExtensionID::SPV_INTEL_kernel_attributes))
4618+
break;
4619+
BF->addExecutionMode(BM->add(
4620+
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4621+
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4622+
BM->addCapability(CapabilityKernelAttributesINTEL);
46204623
} break;
46214624
case spv::ExecutionModeVecTypeHint:
46224625
case spv::ExecutionModeSubgroupSize:
4623-
case spv::ExecutionModeSubgroupsPerWorkgroup: {
4624-
unsigned X;
4625-
N.get(X);
4626-
BF->addExecutionMode(BM->add(
4627-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode), X)));
4628-
} break;
4626+
case spv::ExecutionModeSubgroupsPerWorkgroup:
4627+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4628+
break;
46294629
case spv::ExecutionModeNumSIMDWorkitemsINTEL:
46304630
case spv::ExecutionModeSchedulerTargetFmaxMhzINTEL:
46314631
case spv::ExecutionModeMaxWorkDimINTEL:
46324632
case spv::internal::ExecutionModeStreamingInterfaceINTEL: {
4633-
if (BM->isAllowedToUseExtension(
4634-
ExtensionID::SPV_INTEL_kernel_attributes)) {
4635-
unsigned X;
4636-
N.get(X);
4637-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4638-
BF, static_cast<ExecutionMode>(EMode), X)));
4639-
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4640-
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
4641-
}
4633+
if (!BM->isAllowedToUseExtension(
4634+
ExtensionID::SPV_INTEL_kernel_attributes))
4635+
break;
4636+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4637+
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4638+
BM->addCapability(CapabilityFPGAKernelAttributesINTEL);
46424639
} break;
46434640
case spv::ExecutionModeSharedLocalMemorySizeINTEL: {
46444641
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
46454642
break;
4646-
unsigned SLMSize;
4647-
N.get(SLMSize);
4648-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4649-
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
4643+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
46504644
} break;
46514645
case spv::ExecutionModeNamedBarrierCountINTEL: {
46524646
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
@@ -4664,12 +4658,14 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46644658
case spv::ExecutionModeSignedZeroInfNanPreserve:
46654659
case spv::ExecutionModeRoundingModeRTE:
46664660
case spv::ExecutionModeRoundingModeRTZ: {
4667-
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_float_controls))
4668-
break;
4669-
unsigned TargetWidth;
4670-
N.get(TargetWidth);
4671-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4672-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
4661+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
4662+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
4663+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4664+
} else if (BM->isAllowedToUseExtension(
4665+
ExtensionID::SPV_KHR_float_controls)) {
4666+
BM->addExtension(ExtensionID::SPV_KHR_float_controls);
4667+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4668+
}
46734669
} break;
46744670
case spv::ExecutionModeRoundingModeRTPINTEL:
46754671
case spv::ExecutionModeRoundingModeRTNINTEL:
@@ -4678,10 +4674,7 @@ bool LLVMToSPIRVBase::transExecutionMode() {
46784674
if (!BM->isAllowedToUseExtension(
46794675
ExtensionID::SPV_INTEL_float_controls2))
46804676
break;
4681-
unsigned TargetWidth;
4682-
N.get(TargetWidth);
4683-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4684-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
4677+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
46854678
} break;
46864679
case spv::internal::ExecutionModeFastCompositeKernelINTEL: {
46874680
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)