| 1 |
// GENERATED FILE - DO NOT EDIT. |
| 2 |
// Generated by generate_tests.py |
| 3 |
// |
| 4 |
// Copyright (c) 2022 Google LLC. |
| 5 |
// |
| 6 |
// Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 |
// you may not use this file except in compliance with the License. |
| 8 |
// You may obtain a copy of the License at |
| 9 |
// |
| 10 |
// http://www.apache.org/licenses/LICENSE-2.0 |
| 11 |
// |
| 12 |
// Unless required by applicable law or agreed to in writing, software |
| 13 |
// distributed under the License is distributed on an "AS IS" BASIS, |
| 14 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 |
// See the License for the specific language governing permissions and |
| 16 |
// limitations under the License. |
| 17 |
|
| 18 |
#include "../diff_test_utils.h" |
| 19 |
|
| 20 |
#include "gtest/gtest.h" |
| 21 |
|
| 22 |
namespace spvtools { |
| 23 |
namespace diff { |
| 24 |
namespace { |
| 25 |
|
| 26 |
// Tests OpSpecConstantOp matching. |
| 27 |
constexpr char kSrc[] = R"( OpCapability Shader |
| 28 |
OpMemoryModel Logical GLSL450 |
| 29 |
OpEntryPoint GLCompute %1 "main" |
| 30 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 31 |
%2 = OpTypeVoid |
| 32 |
%3 = OpTypeFunction %2 |
| 33 |
%4 = OpTypeInt 32 0 |
| 34 |
%5 = OpTypeVector %4 3 |
| 35 |
%6 = OpConstant %4 1 |
| 36 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 37 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 38 |
%9 = OpSpecConstantOp %4 CompositeExtract %7 1 |
| 39 |
%10 = OpSpecConstantOp %4 CompositeExtract %7 0 |
| 40 |
%1 = OpFunction %2 None %3 |
| 41 |
%11 = OpLabel |
| 42 |
OpReturn |
| 43 |
OpFunctionEnd)"; |
| 44 |
constexpr char kDst[] = R"( OpCapability Shader |
| 45 |
OpMemoryModel Logical GLSL450 |
| 46 |
OpEntryPoint GLCompute %1 "main" |
| 47 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 48 |
%2 = OpTypeVoid |
| 49 |
%3 = OpTypeFunction %2 |
| 50 |
%4 = OpTypeInt 32 0 |
| 51 |
%5 = OpTypeVector %4 3 |
| 52 |
%6 = OpConstant %4 1 |
| 53 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 54 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 55 |
%9 = OpSpecConstantOp %4 CompositeExtract %7 3 |
| 56 |
%10 = OpSpecConstantOp %4 IMul %8 %8 |
| 57 |
%1 = OpFunction %2 None %3 |
| 58 |
%11 = OpLabel |
| 59 |
OpReturn |
| 60 |
OpFunctionEnd |
| 61 |
)"; |
| 62 |
|
| 63 |
TEST(DiffTest, SpecConstantOp) { |
| 64 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 65 |
; Version: 1.6 |
| 66 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 67 |
-; Bound: 12 |
| 68 |
+; Bound: 14 |
| 69 |
; Schema: 0 |
| 70 |
OpCapability Shader |
| 71 |
OpMemoryModel Logical GLSL450 |
| 72 |
OpEntryPoint GLCompute %1 "main" |
| 73 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 74 |
%2 = OpTypeVoid |
| 75 |
%3 = OpTypeFunction %2 |
| 76 |
%4 = OpTypeInt 32 0 |
| 77 |
%5 = OpTypeVector %4 3 |
| 78 |
%6 = OpConstant %4 1 |
| 79 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 80 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 81 |
-%9 = OpSpecConstantOp %4 CompositeExtract %7 1 |
| 82 |
-%10 = OpSpecConstantOp %4 CompositeExtract %7 0 |
| 83 |
+%12 = OpSpecConstantOp %4 CompositeExtract %7 3 |
| 84 |
+%13 = OpSpecConstantOp %4 IMul %8 %8 |
| 85 |
%1 = OpFunction %2 None %3 |
| 86 |
%11 = OpLabel |
| 87 |
OpReturn |
| 88 |
OpFunctionEnd |
| 89 |
)"; |
| 90 |
Options options; |
| 91 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 92 |
} |
| 93 |
|
| 94 |
TEST(DiffTest, SpecConstantOpNoDebug) { |
| 95 |
constexpr char kSrcNoDebug[] = R"( OpCapability Shader |
| 96 |
OpMemoryModel Logical GLSL450 |
| 97 |
OpEntryPoint GLCompute %1 "main" |
| 98 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 99 |
%2 = OpTypeVoid |
| 100 |
%3 = OpTypeFunction %2 |
| 101 |
%4 = OpTypeInt 32 0 |
| 102 |
%5 = OpTypeVector %4 3 |
| 103 |
%6 = OpConstant %4 1 |
| 104 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 105 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 106 |
%9 = OpSpecConstantOp %4 CompositeExtract %7 1 |
| 107 |
%10 = OpSpecConstantOp %4 CompositeExtract %7 0 |
| 108 |
%1 = OpFunction %2 None %3 |
| 109 |
%11 = OpLabel |
| 110 |
OpReturn |
| 111 |
OpFunctionEnd)"; |
| 112 |
constexpr char kDstNoDebug[] = R"( OpCapability Shader |
| 113 |
OpMemoryModel Logical GLSL450 |
| 114 |
OpEntryPoint GLCompute %1 "main" |
| 115 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 116 |
%2 = OpTypeVoid |
| 117 |
%3 = OpTypeFunction %2 |
| 118 |
%4 = OpTypeInt 32 0 |
| 119 |
%5 = OpTypeVector %4 3 |
| 120 |
%6 = OpConstant %4 1 |
| 121 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 122 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 123 |
%9 = OpSpecConstantOp %4 CompositeExtract %7 3 |
| 124 |
%10 = OpSpecConstantOp %4 IMul %8 %8 |
| 125 |
%1 = OpFunction %2 None %3 |
| 126 |
%11 = OpLabel |
| 127 |
OpReturn |
| 128 |
OpFunctionEnd |
| 129 |
)"; |
| 130 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 131 |
; Version: 1.6 |
| 132 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 133 |
-; Bound: 12 |
| 134 |
+; Bound: 14 |
| 135 |
; Schema: 0 |
| 136 |
OpCapability Shader |
| 137 |
OpMemoryModel Logical GLSL450 |
| 138 |
OpEntryPoint GLCompute %1 "main" |
| 139 |
OpExecutionMode %1 LocalSize 1 1 1 |
| 140 |
%2 = OpTypeVoid |
| 141 |
%3 = OpTypeFunction %2 |
| 142 |
%4 = OpTypeInt 32 0 |
| 143 |
%5 = OpTypeVector %4 3 |
| 144 |
%6 = OpConstant %4 1 |
| 145 |
%7 = OpSpecConstantComposite %5 %6 %6 %6 |
| 146 |
%8 = OpSpecConstantOp %4 CompositeExtract %7 2 |
| 147 |
-%9 = OpSpecConstantOp %4 CompositeExtract %7 1 |
| 148 |
-%10 = OpSpecConstantOp %4 CompositeExtract %7 0 |
| 149 |
+%12 = OpSpecConstantOp %4 CompositeExtract %7 3 |
| 150 |
+%13 = OpSpecConstantOp %4 IMul %8 %8 |
| 151 |
%1 = OpFunction %2 None %3 |
| 152 |
%11 = OpLabel |
| 153 |
OpReturn |
| 154 |
OpFunctionEnd |
| 155 |
)"; |
| 156 |
Options options; |
| 157 |
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); |
| 158 |
} |
| 159 |
|
| 160 |
} // namespace |
| 161 |
} // namespace diff |
| 162 |
} // namespace spvtools |