Skip to content

Commit 812cd8a

Browse files
authored
[SPIR-V] Cherry-pick of "Add SPIR-V 1.4 checks" (#7493)
One of the patches missing in intel/llvm Signed-off-by: Sidorov, Dmitry [email protected] Original commit: KhronosGroup/SPIRV-LLVM-Translator@c5b3c8e3283b Second attempt
1 parent b3b5985 commit 812cd8a

File tree

11 files changed

+131
-104
lines changed

11 files changed

+131
-104
lines changed

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,9 +1488,12 @@ LLVMToSPIRVBase::getLoopControl(const BranchInst *Branch,
14881488
// PartialCount must not be used with the DontUnroll bit
14891489
else if (S == "llvm.loop.unroll.count" &&
14901490
!(LoopControl & LoopControlDontUnrollMask)) {
1491-
size_t I = getMDOperandAsInt(Node, 1);
1492-
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1493-
LoopControl |= spv::LoopControlPartialCountMask;
1491+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
1492+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
1493+
size_t I = getMDOperandAsInt(Node, 1);
1494+
ParametersToSort.emplace_back(spv::LoopControlPartialCountMask, I);
1495+
LoopControl |= spv::LoopControlPartialCountMask;
1496+
}
14941497
} else if (S == "llvm.loop.ivdep.enable")
14951498
LoopControl |= spv::LoopControlDependencyInfiniteMask;
14961499
else if (S == "llvm.loop.ivdep.safelen") {
@@ -2653,10 +2656,10 @@ bool LLVMToSPIRVBase::transDecoration(Value *V, SPIRVValue *BV) {
26532656

26542657
if (auto BVO = dyn_cast_or_null<OverflowingBinaryOperator>(V)) {
26552658
if (BVO->hasNoSignedWrap()) {
2656-
BV->setNoSignedWrap(true);
2659+
BV->setNoIntegerDecorationWrap<DecorationNoSignedWrap>(true);
26572660
}
26582661
if (BVO->hasNoUnsignedWrap()) {
2659-
BV->setNoUnsignedWrap(true);
2662+
BV->setNoIntegerDecorationWrap<DecorationNoUnsignedWrap>(true);
26602663
}
26612664
}
26622665

@@ -4963,22 +4966,19 @@ bool LLVMToSPIRVBase::transExecutionMode() {
49634966
}
49644967
} break;
49654968
case spv::ExecutionModeNoGlobalOffsetINTEL: {
4966-
if (BM->isAllowedToUseExtension(
4967-
ExtensionID::SPV_INTEL_kernel_attributes)) {
4968-
BF->addExecutionMode(BM->add(
4969-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4970-
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4971-
BM->addCapability(CapabilityKernelAttributesINTEL);
4972-
}
4969+
if (!BM->isAllowedToUseExtension(
4970+
ExtensionID::SPV_INTEL_kernel_attributes))
4971+
break;
4972+
BF->addExecutionMode(BM->add(
4973+
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode))));
4974+
BM->addExtension(ExtensionID::SPV_INTEL_kernel_attributes);
4975+
BM->addCapability(CapabilityKernelAttributesINTEL);
49734976
} break;
49744977
case spv::ExecutionModeVecTypeHint:
49754978
case spv::ExecutionModeSubgroupSize:
4976-
case spv::ExecutionModeSubgroupsPerWorkgroup: {
4977-
unsigned X;
4978-
N.get(X);
4979-
BF->addExecutionMode(BM->add(
4980-
new SPIRVExecutionMode(BF, static_cast<ExecutionMode>(EMode), X)));
4981-
} break;
4979+
case spv::ExecutionModeSubgroupsPerWorkgroup:
4980+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
4981+
break;
49824982
case spv::ExecutionModeNumSIMDWorkitemsINTEL:
49834983
case spv::ExecutionModeSchedulerTargetFmaxMhzINTEL:
49844984
case spv::ExecutionModeMaxWorkDimINTEL:
@@ -4993,10 +4993,7 @@ bool LLVMToSPIRVBase::transExecutionMode() {
49934993
case spv::ExecutionModeSharedLocalMemorySizeINTEL: {
49944994
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
49954995
break;
4996-
unsigned SLMSize;
4997-
N.get(SLMSize);
4998-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
4999-
BF, static_cast<ExecutionMode>(EMode), SLMSize)));
4996+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
50004997
} break;
50014998
case spv::ExecutionModeNamedBarrierCountINTEL: {
50024999
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_INTEL_vector_compute))
@@ -5014,12 +5011,14 @@ bool LLVMToSPIRVBase::transExecutionMode() {
50145011
case spv::ExecutionModeSignedZeroInfNanPreserve:
50155012
case spv::ExecutionModeRoundingModeRTE:
50165013
case spv::ExecutionModeRoundingModeRTZ: {
5017-
if (!BM->isAllowedToUseExtension(ExtensionID::SPV_KHR_float_controls))
5018-
break;
5019-
unsigned TargetWidth;
5020-
N.get(TargetWidth);
5021-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
5022-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
5014+
if (BM->isAllowedToUseVersion(VersionNumber::SPIRV_1_4)) {
5015+
BM->setMinSPIRVVersion(VersionNumber::SPIRV_1_4);
5016+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
5017+
} else if (BM->isAllowedToUseExtension(
5018+
ExtensionID::SPV_KHR_float_controls)) {
5019+
BM->addExtension(ExtensionID::SPV_KHR_float_controls);
5020+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
5021+
}
50235022
} break;
50245023
case spv::ExecutionModeRoundingModeRTPINTEL:
50255024
case spv::ExecutionModeRoundingModeRTNINTEL:
@@ -5028,10 +5027,7 @@ bool LLVMToSPIRVBase::transExecutionMode() {
50285027
if (!BM->isAllowedToUseExtension(
50295028
ExtensionID::SPV_INTEL_float_controls2))
50305029
break;
5031-
unsigned TargetWidth;
5032-
N.get(TargetWidth);
5033-
BF->addExecutionMode(BM->add(new SPIRVExecutionMode(
5034-
BF, static_cast<ExecutionMode>(EMode), TargetWidth)));
5030+
AddSingleArgExecutionMode(static_cast<ExecutionMode>(EMode));
50355031
} break;
50365032
case spv::internal::ExecutionModeFastCompositeKernelINTEL: {
50375033
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
std::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
@@ -845,12 +845,6 @@ class SPIRVCapability : public SPIRVEntryNoId<OpCapability> {
845845

846846
std::optional<ExtensionID> getRequiredExtension() const override {
847847
switch (static_cast<unsigned>(Kind)) {
848-
case CapabilityDenormPreserve:
849-
case CapabilityDenormFlushToZero:
850-
case CapabilitySignedZeroInfNanPreserve:
851-
case CapabilityRoundingModeRTE:
852-
case CapabilityRoundingModeRTZ:
853-
return ExtensionID::SPV_KHR_float_controls;
854848
case CapabilityRoundToInfinityINTEL:
855849
case CapabilityFloatingPointModeINTEL:
856850
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/extensions/INTEL/SPV_INTEL_vector_compute/exec_mode_float_control.ll

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
11
; RUN: llvm-as %s -o %t.bc
2-
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_INTEL_vector_compute,+SPV_KHR_float_controls,+SPV_INTEL_float_controls2
2+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.1 --spirv-ext=+SPV_INTEL_vector_compute,+SPV_KHR_float_controls,+SPV_INTEL_float_controls2
33
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
44
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.bc
55
; RUN: llvm-dis %t.bc -o %t.ll
6-
; RUN: FileCheck %s --input-file %t.spt -check-prefix=SPV
6+
; RUN: FileCheck %s --input-file %t.spt -check-prefixes=SPV,SPVEXT
77
; RUN: FileCheck %s --input-file %t.ll -check-prefix=LLVM
88

9+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.4 --spirv-ext=+SPV_INTEL_vector_compute,+SPV_INTEL_float_controls2
10+
; RUN: llvm-spirv %t.spv -o %t.spt --to-text
11+
; RUN: FileCheck %s --input-file %t.spt -check-prefixes=SPV,SPV14
12+
913

1014
; ModuleID = 'float_control.bc'
1115
source_filename = "float_control.cpp"
1216
target datalayout = "e-p:64:64-i64:64-n8:16:32"
1317
target triple = "spir"
1418

1519

16-
; SPV-DAG: Extension "SPV_KHR_float_controls"
20+
; SPVEXT-DAG: Extension "SPV_KHR_float_controls"
21+
; SPV14-NOT: Extension "SPV_KHR_float_controls"
1722
; SPV-DAG: Extension "SPV_INTEL_float_controls2"
1823

1924
; LLVM-DAG: @k_rte{{[^a-zA-Z0-9_][^#]*}}#[[K_RTE:[0-9]+]]

llvm-spirv/test/extensions/KHR/SPV_KHR_float_controls/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/extensions/KHR/SPV_KHR_no_integer_wrap_decoration/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
}

llvm-spirv/test/transcoding/LoopUnroll.ll

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
5353
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
5454
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefixes=CHECK-LLVM
55+
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-max-version=1.1
56+
; RUN: llvm-spirv -to-text %t.spv -o %t.spt
57+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV-NEGATIVE
58+
59+
; Check SPIR-V versions in a format magic number + version
60+
; CHECK-SPIRV: 119734787 66560
61+
; CHECK-SPIRV-NEGATIVE: 119734787 65536
5562

5663
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
5764
target triple = "spir64"
@@ -125,6 +132,7 @@ while.cond: ; preds = %if.end, %if.then, %
125132
; Per SPIRV spec p3.23 "Unroll" loop control = 0x1
126133
; CHECK-SPIRV: LoopMerge [[#MERGEBLOCK:]] [[#CONTINUE:]] 256 8
127134
; CHECK-SPIRV: BranchConditional [[#]] [[#]] [[#MERGEBLOCK]]
135+
; CHECK-SPIRV-NEGATIVE-NOT: LoopMerge {{.*}} 256
128136
br i1 %cmp, label %while.body, label %while.end
129137

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

llvm-spirv/test/transcoding/annotate_attribute.ll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
; RUN: llvm-as -opaque-pointers=0 %s -o %t.bc
1111
; RUN: llvm-spirv %t.bc -opaque-pointers=0 --spirv-ext=+SPV_INTEL_fpga_memory_accesses,+SPV_INTEL_fpga_memory_attributes -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
1212

13+
; Check SPIR-V versions in a format magic number + version
14+
; CHECK-SPIRV: 119734787 66560
15+
1316
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} UserSemantic "42"
1417
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} UserSemantic "bar"
1518
; CHECK-SPIRV-DAG: Decorate {{[0-9]+}} UserSemantic "{FOO}"

0 commit comments

Comments
 (0)