| 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 |
// Test where src has an extra if block in one function, and dst has an extra |
| 27 |
// if block in another function. |
| 28 |
constexpr char kSrc[] = R"( OpCapability Shader |
| 29 |
%1 = OpExtInstImport "GLSL.std.450" |
| 30 |
OpMemoryModel Logical GLSL450 |
| 31 |
OpEntryPoint Fragment %4 "main" %63 %68 |
| 32 |
OpExecutionMode %4 OriginUpperLeft |
| 33 |
OpSource ESSL 310 |
| 34 |
OpName %4 "main" |
| 35 |
OpName %8 "f1(" |
| 36 |
OpName %10 "f2(" |
| 37 |
OpName %13 "v" |
| 38 |
OpName %16 "Buffer" |
| 39 |
OpMemberName %16 0 "flag1" |
| 40 |
OpMemberName %16 1 "flag2" |
| 41 |
OpName %18 "" |
| 42 |
OpName %45 "v" |
| 43 |
OpName %63 "color" |
| 44 |
OpName %68 "v" |
| 45 |
OpDecorate %8 RelaxedPrecision |
| 46 |
OpDecorate %10 RelaxedPrecision |
| 47 |
OpDecorate %13 RelaxedPrecision |
| 48 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 49 |
OpMemberDecorate %16 0 Offset 0 |
| 50 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 51 |
OpMemberDecorate %16 1 Offset 4 |
| 52 |
OpDecorate %16 Block |
| 53 |
OpDecorate %18 DescriptorSet 0 |
| 54 |
OpDecorate %18 Binding 0 |
| 55 |
OpDecorate %23 RelaxedPrecision |
| 56 |
OpDecorate %30 RelaxedPrecision |
| 57 |
OpDecorate %31 RelaxedPrecision |
| 58 |
OpDecorate %34 RelaxedPrecision |
| 59 |
OpDecorate %35 RelaxedPrecision |
| 60 |
OpDecorate %36 RelaxedPrecision |
| 61 |
OpDecorate %37 RelaxedPrecision |
| 62 |
OpDecorate %38 RelaxedPrecision |
| 63 |
OpDecorate %39 RelaxedPrecision |
| 64 |
OpDecorate %40 RelaxedPrecision |
| 65 |
OpDecorate %41 RelaxedPrecision |
| 66 |
OpDecorate %42 RelaxedPrecision |
| 67 |
OpDecorate %45 RelaxedPrecision |
| 68 |
OpDecorate %47 RelaxedPrecision |
| 69 |
OpDecorate %48 RelaxedPrecision |
| 70 |
OpDecorate %50 RelaxedPrecision |
| 71 |
OpDecorate %51 RelaxedPrecision |
| 72 |
OpDecorate %54 RelaxedPrecision |
| 73 |
OpDecorate %55 RelaxedPrecision |
| 74 |
OpDecorate %56 RelaxedPrecision |
| 75 |
OpDecorate %57 RelaxedPrecision |
| 76 |
OpDecorate %58 RelaxedPrecision |
| 77 |
OpDecorate %63 RelaxedPrecision |
| 78 |
OpDecorate %63 Location 0 |
| 79 |
OpDecorate %64 RelaxedPrecision |
| 80 |
OpDecorate %65 RelaxedPrecision |
| 81 |
OpDecorate %66 RelaxedPrecision |
| 82 |
OpDecorate %68 RelaxedPrecision |
| 83 |
OpDecorate %68 Location 0 |
| 84 |
%2 = OpTypeVoid |
| 85 |
%3 = OpTypeFunction %2 |
| 86 |
%6 = OpTypeFloat 32 |
| 87 |
%7 = OpTypeFunction %6 |
| 88 |
%12 = OpTypePointer Function %6 |
| 89 |
%14 = OpConstant %6 0 |
| 90 |
%15 = OpTypeInt 32 0 |
| 91 |
%16 = OpTypeStruct %15 %15 |
| 92 |
%17 = OpTypePointer Uniform %16 |
| 93 |
%18 = OpVariable %17 Uniform |
| 94 |
%19 = OpTypeInt 32 1 |
| 95 |
%20 = OpConstant %19 0 |
| 96 |
%21 = OpTypePointer Uniform %15 |
| 97 |
%24 = OpConstant %15 0 |
| 98 |
%25 = OpTypeBool |
| 99 |
%29 = OpConstant %6 1 |
| 100 |
%32 = OpConstant %19 1 |
| 101 |
%49 = OpConstant %6 10 |
| 102 |
%52 = OpConstant %6 0.5 |
| 103 |
%53 = OpConstant %6 0.699999988 |
| 104 |
%61 = OpTypeVector %6 4 |
| 105 |
%62 = OpTypePointer Output %61 |
| 106 |
%63 = OpVariable %62 Output |
| 107 |
%67 = OpTypePointer Input %6 |
| 108 |
%68 = OpVariable %67 Input |
| 109 |
%4 = OpFunction %2 None %3 |
| 110 |
%5 = OpLabel |
| 111 |
%64 = OpFunctionCall %6 %8 |
| 112 |
%65 = OpFunctionCall %6 %10 |
| 113 |
%66 = OpCompositeConstruct %61 %64 %65 %14 %29 |
| 114 |
OpStore %63 %66 |
| 115 |
OpReturn |
| 116 |
OpFunctionEnd |
| 117 |
%8 = OpFunction %6 None %7 |
| 118 |
%9 = OpLabel |
| 119 |
%13 = OpVariable %12 Function |
| 120 |
OpStore %13 %14 |
| 121 |
%22 = OpAccessChain %21 %18 %20 |
| 122 |
%23 = OpLoad %15 %22 |
| 123 |
%26 = OpINotEqual %25 %23 %24 |
| 124 |
OpSelectionMerge %28 None |
| 125 |
OpBranchConditional %26 %27 %28 |
| 126 |
%27 = OpLabel |
| 127 |
%30 = OpLoad %6 %13 |
| 128 |
%31 = OpFAdd %6 %30 %29 |
| 129 |
OpStore %13 %31 |
| 130 |
OpBranch %28 |
| 131 |
%28 = OpLabel |
| 132 |
%33 = OpAccessChain %21 %18 %32 |
| 133 |
%34 = OpLoad %15 %33 |
| 134 |
%35 = OpConvertUToF %6 %34 |
| 135 |
%36 = OpExtInst %6 %1 Log2 %35 |
| 136 |
%37 = OpLoad %6 %13 |
| 137 |
%38 = OpFAdd %6 %37 %36 |
| 138 |
OpStore %13 %38 |
| 139 |
%39 = OpLoad %6 %13 |
| 140 |
%40 = OpLoad %6 %13 |
| 141 |
%41 = OpExtInst %6 %1 Sqrt %40 |
| 142 |
%42 = OpFSub %6 %39 %41 |
| 143 |
OpReturnValue %42 |
| 144 |
OpFunctionEnd |
| 145 |
%10 = OpFunction %6 None %7 |
| 146 |
%11 = OpLabel |
| 147 |
%45 = OpVariable %12 Function |
| 148 |
%46 = OpAccessChain %21 %18 %20 |
| 149 |
%47 = OpLoad %15 %46 |
| 150 |
%48 = OpConvertUToF %6 %47 |
| 151 |
%50 = OpFDiv %6 %48 %49 |
| 152 |
OpStore %45 %50 |
| 153 |
%51 = OpLoad %6 %45 |
| 154 |
%54 = OpExtInst %6 %1 FClamp %51 %52 %53 |
| 155 |
%55 = OpLoad %6 %45 |
| 156 |
%56 = OpFMul %6 %55 %54 |
| 157 |
OpStore %45 %56 |
| 158 |
%57 = OpLoad %6 %45 |
| 159 |
%58 = OpExtInst %6 %1 Exp %57 |
| 160 |
OpReturnValue %58 |
| 161 |
OpFunctionEnd |
| 162 |
)"; |
| 163 |
constexpr char kDst[] = R"( OpCapability Shader |
| 164 |
%1 = OpExtInstImport "GLSL.std.450" |
| 165 |
OpMemoryModel Logical GLSL450 |
| 166 |
OpEntryPoint Fragment %4 "main" %63 %69 |
| 167 |
OpExecutionMode %4 OriginUpperLeft |
| 168 |
OpSource ESSL 310 |
| 169 |
OpName %4 "main" |
| 170 |
OpName %8 "f1(" |
| 171 |
OpName %10 "f2(" |
| 172 |
OpName %13 "v" |
| 173 |
OpName %16 "Buffer" |
| 174 |
OpMemberName %16 0 "flag1" |
| 175 |
OpMemberName %16 1 "flag2" |
| 176 |
OpName %18 "" |
| 177 |
OpName %34 "v" |
| 178 |
OpName %63 "color" |
| 179 |
OpName %69 "v" |
| 180 |
OpDecorate %8 RelaxedPrecision |
| 181 |
OpDecorate %10 RelaxedPrecision |
| 182 |
OpDecorate %13 RelaxedPrecision |
| 183 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 184 |
OpMemberDecorate %16 0 Offset 0 |
| 185 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 186 |
OpMemberDecorate %16 1 Offset 4 |
| 187 |
OpDecorate %16 Block |
| 188 |
OpDecorate %18 DescriptorSet 0 |
| 189 |
OpDecorate %18 Binding 0 |
| 190 |
OpDecorate %23 RelaxedPrecision |
| 191 |
OpDecorate %24 RelaxedPrecision |
| 192 |
OpDecorate %25 RelaxedPrecision |
| 193 |
OpDecorate %26 RelaxedPrecision |
| 194 |
OpDecorate %27 RelaxedPrecision |
| 195 |
OpDecorate %28 RelaxedPrecision |
| 196 |
OpDecorate %29 RelaxedPrecision |
| 197 |
OpDecorate %30 RelaxedPrecision |
| 198 |
OpDecorate %31 RelaxedPrecision |
| 199 |
OpDecorate %34 RelaxedPrecision |
| 200 |
OpDecorate %37 RelaxedPrecision |
| 201 |
OpDecorate %38 RelaxedPrecision |
| 202 |
OpDecorate %40 RelaxedPrecision |
| 203 |
OpDecorate %41 RelaxedPrecision |
| 204 |
OpDecorate %44 RelaxedPrecision |
| 205 |
OpDecorate %45 RelaxedPrecision |
| 206 |
OpDecorate %46 RelaxedPrecision |
| 207 |
OpDecorate %48 RelaxedPrecision |
| 208 |
OpDecorate %55 RelaxedPrecision |
| 209 |
OpDecorate %56 RelaxedPrecision |
| 210 |
OpDecorate %57 RelaxedPrecision |
| 211 |
OpDecorate %58 RelaxedPrecision |
| 212 |
OpDecorate %63 RelaxedPrecision |
| 213 |
OpDecorate %63 Location 0 |
| 214 |
OpDecorate %64 RelaxedPrecision |
| 215 |
OpDecorate %65 RelaxedPrecision |
| 216 |
OpDecorate %67 RelaxedPrecision |
| 217 |
OpDecorate %69 RelaxedPrecision |
| 218 |
OpDecorate %69 Location 0 |
| 219 |
%2 = OpTypeVoid |
| 220 |
%3 = OpTypeFunction %2 |
| 221 |
%6 = OpTypeFloat 32 |
| 222 |
%7 = OpTypeFunction %6 |
| 223 |
%12 = OpTypePointer Function %6 |
| 224 |
%14 = OpConstant %6 0 |
| 225 |
%15 = OpTypeInt 32 0 |
| 226 |
%16 = OpTypeStruct %15 %15 |
| 227 |
%17 = OpTypePointer Uniform %16 |
| 228 |
%18 = OpVariable %17 Uniform |
| 229 |
%19 = OpTypeInt 32 1 |
| 230 |
%20 = OpConstant %19 1 |
| 231 |
%21 = OpTypePointer Uniform %15 |
| 232 |
%35 = OpConstant %19 0 |
| 233 |
%39 = OpConstant %6 10 |
| 234 |
%42 = OpConstant %6 0.5 |
| 235 |
%43 = OpConstant %6 0.699999988 |
| 236 |
%49 = OpConstant %15 0 |
| 237 |
%50 = OpTypeBool |
| 238 |
%54 = OpConstant %6 0.100000001 |
| 239 |
%61 = OpTypeVector %6 4 |
| 240 |
%62 = OpTypePointer Output %61 |
| 241 |
%63 = OpVariable %62 Output |
| 242 |
%66 = OpConstant %6 1 |
| 243 |
%68 = OpTypePointer Input %6 |
| 244 |
%69 = OpVariable %68 Input |
| 245 |
%4 = OpFunction %2 None %3 |
| 246 |
%5 = OpLabel |
| 247 |
%64 = OpFunctionCall %6 %8 |
| 248 |
%65 = OpFunctionCall %6 %10 |
| 249 |
%67 = OpCompositeConstruct %61 %64 %65 %14 %66 |
| 250 |
OpStore %63 %67 |
| 251 |
OpReturn |
| 252 |
OpFunctionEnd |
| 253 |
%8 = OpFunction %6 None %7 |
| 254 |
%9 = OpLabel |
| 255 |
%13 = OpVariable %12 Function |
| 256 |
OpStore %13 %14 |
| 257 |
%22 = OpAccessChain %21 %18 %20 |
| 258 |
%23 = OpLoad %15 %22 |
| 259 |
%24 = OpConvertUToF %6 %23 |
| 260 |
%25 = OpExtInst %6 %1 Log2 %24 |
| 261 |
%26 = OpLoad %6 %13 |
| 262 |
%27 = OpFAdd %6 %26 %25 |
| 263 |
OpStore %13 %27 |
| 264 |
%28 = OpLoad %6 %13 |
| 265 |
%29 = OpLoad %6 %13 |
| 266 |
%30 = OpExtInst %6 %1 Sqrt %29 |
| 267 |
%31 = OpFSub %6 %28 %30 |
| 268 |
OpReturnValue %31 |
| 269 |
OpFunctionEnd |
| 270 |
%10 = OpFunction %6 None %7 |
| 271 |
%11 = OpLabel |
| 272 |
%34 = OpVariable %12 Function |
| 273 |
%36 = OpAccessChain %21 %18 %35 |
| 274 |
%37 = OpLoad %15 %36 |
| 275 |
%38 = OpConvertUToF %6 %37 |
| 276 |
%40 = OpFDiv %6 %38 %39 |
| 277 |
OpStore %34 %40 |
| 278 |
%41 = OpLoad %6 %34 |
| 279 |
%44 = OpExtInst %6 %1 FClamp %41 %42 %43 |
| 280 |
%45 = OpLoad %6 %34 |
| 281 |
%46 = OpFMul %6 %45 %44 |
| 282 |
OpStore %34 %46 |
| 283 |
%47 = OpAccessChain %21 %18 %20 |
| 284 |
%48 = OpLoad %15 %47 |
| 285 |
%51 = OpINotEqual %50 %48 %49 |
| 286 |
OpSelectionMerge %53 None |
| 287 |
OpBranchConditional %51 %52 %53 |
| 288 |
%52 = OpLabel |
| 289 |
%55 = OpLoad %6 %34 |
| 290 |
%56 = OpFSub %6 %55 %54 |
| 291 |
OpStore %34 %56 |
| 292 |
OpBranch %53 |
| 293 |
%53 = OpLabel |
| 294 |
%57 = OpLoad %6 %34 |
| 295 |
%58 = OpExtInst %6 %1 Exp %57 |
| 296 |
OpReturnValue %58 |
| 297 |
OpFunctionEnd |
| 298 |
|
| 299 |
)"; |
| 300 |
|
| 301 |
TEST(DiffTest, ExtraIfBlock) { |
| 302 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 303 |
; Version: 1.6 |
| 304 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 305 |
-; Bound: 69 |
| 306 |
+; Bound: 77 |
| 307 |
; Schema: 0 |
| 308 |
OpCapability Shader |
| 309 |
%1 = OpExtInstImport "GLSL.std.450" |
| 310 |
OpMemoryModel Logical GLSL450 |
| 311 |
OpEntryPoint Fragment %4 "main" %63 %68 |
| 312 |
OpExecutionMode %4 OriginUpperLeft |
| 313 |
OpSource ESSL 310 |
| 314 |
OpName %4 "main" |
| 315 |
OpName %8 "f1(" |
| 316 |
OpName %10 "f2(" |
| 317 |
OpName %13 "v" |
| 318 |
OpName %16 "Buffer" |
| 319 |
OpMemberName %16 0 "flag1" |
| 320 |
OpMemberName %16 1 "flag2" |
| 321 |
OpName %18 "" |
| 322 |
OpName %45 "v" |
| 323 |
OpName %63 "color" |
| 324 |
OpName %68 "v" |
| 325 |
OpDecorate %8 RelaxedPrecision |
| 326 |
OpDecorate %10 RelaxedPrecision |
| 327 |
OpDecorate %13 RelaxedPrecision |
| 328 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 329 |
OpMemberDecorate %16 0 Offset 0 |
| 330 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 331 |
OpMemberDecorate %16 1 Offset 4 |
| 332 |
OpDecorate %16 Block |
| 333 |
OpDecorate %18 DescriptorSet 0 |
| 334 |
OpDecorate %18 Binding 0 |
| 335 |
-OpDecorate %23 RelaxedPrecision |
| 336 |
-OpDecorate %30 RelaxedPrecision |
| 337 |
-OpDecorate %31 RelaxedPrecision |
| 338 |
OpDecorate %34 RelaxedPrecision |
| 339 |
OpDecorate %35 RelaxedPrecision |
| 340 |
OpDecorate %36 RelaxedPrecision |
| 341 |
OpDecorate %37 RelaxedPrecision |
| 342 |
OpDecorate %38 RelaxedPrecision |
| 343 |
OpDecorate %39 RelaxedPrecision |
| 344 |
OpDecorate %40 RelaxedPrecision |
| 345 |
OpDecorate %41 RelaxedPrecision |
| 346 |
OpDecorate %42 RelaxedPrecision |
| 347 |
OpDecorate %45 RelaxedPrecision |
| 348 |
OpDecorate %47 RelaxedPrecision |
| 349 |
OpDecorate %48 RelaxedPrecision |
| 350 |
OpDecorate %50 RelaxedPrecision |
| 351 |
OpDecorate %51 RelaxedPrecision |
| 352 |
OpDecorate %54 RelaxedPrecision |
| 353 |
OpDecorate %55 RelaxedPrecision |
| 354 |
OpDecorate %56 RelaxedPrecision |
| 355 |
+OpDecorate %70 RelaxedPrecision |
| 356 |
OpDecorate %57 RelaxedPrecision |
| 357 |
+OpDecorate %75 RelaxedPrecision |
| 358 |
+OpDecorate %76 RelaxedPrecision |
| 359 |
OpDecorate %58 RelaxedPrecision |
| 360 |
OpDecorate %63 RelaxedPrecision |
| 361 |
OpDecorate %63 Location 0 |
| 362 |
OpDecorate %64 RelaxedPrecision |
| 363 |
OpDecorate %65 RelaxedPrecision |
| 364 |
OpDecorate %66 RelaxedPrecision |
| 365 |
OpDecorate %68 RelaxedPrecision |
| 366 |
OpDecorate %68 Location 0 |
| 367 |
%2 = OpTypeVoid |
| 368 |
%3 = OpTypeFunction %2 |
| 369 |
%6 = OpTypeFloat 32 |
| 370 |
%7 = OpTypeFunction %6 |
| 371 |
%12 = OpTypePointer Function %6 |
| 372 |
%14 = OpConstant %6 0 |
| 373 |
%15 = OpTypeInt 32 0 |
| 374 |
%16 = OpTypeStruct %15 %15 |
| 375 |
%17 = OpTypePointer Uniform %16 |
| 376 |
%18 = OpVariable %17 Uniform |
| 377 |
%19 = OpTypeInt 32 1 |
| 378 |
%20 = OpConstant %19 0 |
| 379 |
%21 = OpTypePointer Uniform %15 |
| 380 |
%24 = OpConstant %15 0 |
| 381 |
%25 = OpTypeBool |
| 382 |
%29 = OpConstant %6 1 |
| 383 |
%32 = OpConstant %19 1 |
| 384 |
%49 = OpConstant %6 10 |
| 385 |
%52 = OpConstant %6 0.5 |
| 386 |
+%74 = OpConstant %6 0.100000001 |
| 387 |
%53 = OpConstant %6 0.699999988 |
| 388 |
%61 = OpTypeVector %6 4 |
| 389 |
%62 = OpTypePointer Output %61 |
| 390 |
%63 = OpVariable %62 Output |
| 391 |
%67 = OpTypePointer Input %6 |
| 392 |
%68 = OpVariable %67 Input |
| 393 |
%4 = OpFunction %2 None %3 |
| 394 |
%5 = OpLabel |
| 395 |
%64 = OpFunctionCall %6 %8 |
| 396 |
%65 = OpFunctionCall %6 %10 |
| 397 |
%66 = OpCompositeConstruct %61 %64 %65 %14 %29 |
| 398 |
OpStore %63 %66 |
| 399 |
OpReturn |
| 400 |
OpFunctionEnd |
| 401 |
%8 = OpFunction %6 None %7 |
| 402 |
%9 = OpLabel |
| 403 |
%13 = OpVariable %12 Function |
| 404 |
OpStore %13 %14 |
| 405 |
-%22 = OpAccessChain %21 %18 %20 |
| 406 |
-%23 = OpLoad %15 %22 |
| 407 |
-%26 = OpINotEqual %25 %23 %24 |
| 408 |
-OpSelectionMerge %28 None |
| 409 |
-OpBranchConditional %26 %27 %28 |
| 410 |
-%27 = OpLabel |
| 411 |
-%30 = OpLoad %6 %13 |
| 412 |
-%31 = OpFAdd %6 %30 %29 |
| 413 |
-OpStore %13 %31 |
| 414 |
-OpBranch %28 |
| 415 |
-%28 = OpLabel |
| 416 |
%33 = OpAccessChain %21 %18 %32 |
| 417 |
%34 = OpLoad %15 %33 |
| 418 |
%35 = OpConvertUToF %6 %34 |
| 419 |
%36 = OpExtInst %6 %1 Log2 %35 |
| 420 |
%37 = OpLoad %6 %13 |
| 421 |
%38 = OpFAdd %6 %37 %36 |
| 422 |
OpStore %13 %38 |
| 423 |
%39 = OpLoad %6 %13 |
| 424 |
%40 = OpLoad %6 %13 |
| 425 |
%41 = OpExtInst %6 %1 Sqrt %40 |
| 426 |
%42 = OpFSub %6 %39 %41 |
| 427 |
OpReturnValue %42 |
| 428 |
OpFunctionEnd |
| 429 |
%10 = OpFunction %6 None %7 |
| 430 |
%11 = OpLabel |
| 431 |
%45 = OpVariable %12 Function |
| 432 |
%46 = OpAccessChain %21 %18 %20 |
| 433 |
%47 = OpLoad %15 %46 |
| 434 |
%48 = OpConvertUToF %6 %47 |
| 435 |
%50 = OpFDiv %6 %48 %49 |
| 436 |
OpStore %45 %50 |
| 437 |
%51 = OpLoad %6 %45 |
| 438 |
%54 = OpExtInst %6 %1 FClamp %51 %52 %53 |
| 439 |
%55 = OpLoad %6 %45 |
| 440 |
%56 = OpFMul %6 %55 %54 |
| 441 |
OpStore %45 %56 |
| 442 |
+%69 = OpAccessChain %21 %18 %32 |
| 443 |
+%70 = OpLoad %15 %69 |
| 444 |
+%71 = OpINotEqual %25 %70 %24 |
| 445 |
+OpSelectionMerge %73 None |
| 446 |
+OpBranchConditional %71 %72 %73 |
| 447 |
+%72 = OpLabel |
| 448 |
%57 = OpLoad %6 %45 |
| 449 |
+%75 = OpFSub %6 %57 %74 |
| 450 |
+OpStore %45 %75 |
| 451 |
+OpBranch %73 |
| 452 |
+%73 = OpLabel |
| 453 |
+%76 = OpLoad %6 %45 |
| 454 |
-%58 = OpExtInst %6 %1 Exp %57 |
| 455 |
+%58 = OpExtInst %6 %1 Exp %76 |
| 456 |
OpReturnValue %58 |
| 457 |
OpFunctionEnd |
| 458 |
)"; |
| 459 |
Options options; |
| 460 |
DoStringDiffTest(kSrc, kDst, kDiff, options); |
| 461 |
} |
| 462 |
|
| 463 |
TEST(DiffTest, ExtraIfBlockNoDebug) { |
| 464 |
constexpr char kSrcNoDebug[] = R"( OpCapability Shader |
| 465 |
%1 = OpExtInstImport "GLSL.std.450" |
| 466 |
OpMemoryModel Logical GLSL450 |
| 467 |
OpEntryPoint Fragment %4 "main" %63 %68 |
| 468 |
OpExecutionMode %4 OriginUpperLeft |
| 469 |
OpSource ESSL 310 |
| 470 |
OpDecorate %8 RelaxedPrecision |
| 471 |
OpDecorate %10 RelaxedPrecision |
| 472 |
OpDecorate %13 RelaxedPrecision |
| 473 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 474 |
OpMemberDecorate %16 0 Offset 0 |
| 475 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 476 |
OpMemberDecorate %16 1 Offset 4 |
| 477 |
OpDecorate %16 Block |
| 478 |
OpDecorate %18 DescriptorSet 0 |
| 479 |
OpDecorate %18 Binding 0 |
| 480 |
OpDecorate %23 RelaxedPrecision |
| 481 |
OpDecorate %30 RelaxedPrecision |
| 482 |
OpDecorate %31 RelaxedPrecision |
| 483 |
OpDecorate %34 RelaxedPrecision |
| 484 |
OpDecorate %35 RelaxedPrecision |
| 485 |
OpDecorate %36 RelaxedPrecision |
| 486 |
OpDecorate %37 RelaxedPrecision |
| 487 |
OpDecorate %38 RelaxedPrecision |
| 488 |
OpDecorate %39 RelaxedPrecision |
| 489 |
OpDecorate %40 RelaxedPrecision |
| 490 |
OpDecorate %41 RelaxedPrecision |
| 491 |
OpDecorate %42 RelaxedPrecision |
| 492 |
OpDecorate %45 RelaxedPrecision |
| 493 |
OpDecorate %47 RelaxedPrecision |
| 494 |
OpDecorate %48 RelaxedPrecision |
| 495 |
OpDecorate %50 RelaxedPrecision |
| 496 |
OpDecorate %51 RelaxedPrecision |
| 497 |
OpDecorate %54 RelaxedPrecision |
| 498 |
OpDecorate %55 RelaxedPrecision |
| 499 |
OpDecorate %56 RelaxedPrecision |
| 500 |
OpDecorate %57 RelaxedPrecision |
| 501 |
OpDecorate %58 RelaxedPrecision |
| 502 |
OpDecorate %63 RelaxedPrecision |
| 503 |
OpDecorate %63 Location 0 |
| 504 |
OpDecorate %64 RelaxedPrecision |
| 505 |
OpDecorate %65 RelaxedPrecision |
| 506 |
OpDecorate %66 RelaxedPrecision |
| 507 |
OpDecorate %68 RelaxedPrecision |
| 508 |
OpDecorate %68 Location 0 |
| 509 |
%2 = OpTypeVoid |
| 510 |
%3 = OpTypeFunction %2 |
| 511 |
%6 = OpTypeFloat 32 |
| 512 |
%7 = OpTypeFunction %6 |
| 513 |
%12 = OpTypePointer Function %6 |
| 514 |
%14 = OpConstant %6 0 |
| 515 |
%15 = OpTypeInt 32 0 |
| 516 |
%16 = OpTypeStruct %15 %15 |
| 517 |
%17 = OpTypePointer Uniform %16 |
| 518 |
%18 = OpVariable %17 Uniform |
| 519 |
%19 = OpTypeInt 32 1 |
| 520 |
%20 = OpConstant %19 0 |
| 521 |
%21 = OpTypePointer Uniform %15 |
| 522 |
%24 = OpConstant %15 0 |
| 523 |
%25 = OpTypeBool |
| 524 |
%29 = OpConstant %6 1 |
| 525 |
%32 = OpConstant %19 1 |
| 526 |
%49 = OpConstant %6 10 |
| 527 |
%52 = OpConstant %6 0.5 |
| 528 |
%53 = OpConstant %6 0.699999988 |
| 529 |
%61 = OpTypeVector %6 4 |
| 530 |
%62 = OpTypePointer Output %61 |
| 531 |
%63 = OpVariable %62 Output |
| 532 |
%67 = OpTypePointer Input %6 |
| 533 |
%68 = OpVariable %67 Input |
| 534 |
%4 = OpFunction %2 None %3 |
| 535 |
%5 = OpLabel |
| 536 |
%64 = OpFunctionCall %6 %8 |
| 537 |
%65 = OpFunctionCall %6 %10 |
| 538 |
%66 = OpCompositeConstruct %61 %64 %65 %14 %29 |
| 539 |
OpStore %63 %66 |
| 540 |
OpReturn |
| 541 |
OpFunctionEnd |
| 542 |
%8 = OpFunction %6 None %7 |
| 543 |
%9 = OpLabel |
| 544 |
%13 = OpVariable %12 Function |
| 545 |
OpStore %13 %14 |
| 546 |
%22 = OpAccessChain %21 %18 %20 |
| 547 |
%23 = OpLoad %15 %22 |
| 548 |
%26 = OpINotEqual %25 %23 %24 |
| 549 |
OpSelectionMerge %28 None |
| 550 |
OpBranchConditional %26 %27 %28 |
| 551 |
%27 = OpLabel |
| 552 |
%30 = OpLoad %6 %13 |
| 553 |
%31 = OpFAdd %6 %30 %29 |
| 554 |
OpStore %13 %31 |
| 555 |
OpBranch %28 |
| 556 |
%28 = OpLabel |
| 557 |
%33 = OpAccessChain %21 %18 %32 |
| 558 |
%34 = OpLoad %15 %33 |
| 559 |
%35 = OpConvertUToF %6 %34 |
| 560 |
%36 = OpExtInst %6 %1 Log2 %35 |
| 561 |
%37 = OpLoad %6 %13 |
| 562 |
%38 = OpFAdd %6 %37 %36 |
| 563 |
OpStore %13 %38 |
| 564 |
%39 = OpLoad %6 %13 |
| 565 |
%40 = OpLoad %6 %13 |
| 566 |
%41 = OpExtInst %6 %1 Sqrt %40 |
| 567 |
%42 = OpFSub %6 %39 %41 |
| 568 |
OpReturnValue %42 |
| 569 |
OpFunctionEnd |
| 570 |
%10 = OpFunction %6 None %7 |
| 571 |
%11 = OpLabel |
| 572 |
%45 = OpVariable %12 Function |
| 573 |
%46 = OpAccessChain %21 %18 %20 |
| 574 |
%47 = OpLoad %15 %46 |
| 575 |
%48 = OpConvertUToF %6 %47 |
| 576 |
%50 = OpFDiv %6 %48 %49 |
| 577 |
OpStore %45 %50 |
| 578 |
%51 = OpLoad %6 %45 |
| 579 |
%54 = OpExtInst %6 %1 FClamp %51 %52 %53 |
| 580 |
%55 = OpLoad %6 %45 |
| 581 |
%56 = OpFMul %6 %55 %54 |
| 582 |
OpStore %45 %56 |
| 583 |
%57 = OpLoad %6 %45 |
| 584 |
%58 = OpExtInst %6 %1 Exp %57 |
| 585 |
OpReturnValue %58 |
| 586 |
OpFunctionEnd |
| 587 |
|
| 588 |
)"; |
| 589 |
constexpr char kDstNoDebug[] = R"( OpCapability Shader |
| 590 |
%1 = OpExtInstImport "GLSL.std.450" |
| 591 |
OpMemoryModel Logical GLSL450 |
| 592 |
OpEntryPoint Fragment %4 "main" %63 %69 |
| 593 |
OpExecutionMode %4 OriginUpperLeft |
| 594 |
OpSource ESSL 310 |
| 595 |
OpDecorate %8 RelaxedPrecision |
| 596 |
OpDecorate %10 RelaxedPrecision |
| 597 |
OpDecorate %13 RelaxedPrecision |
| 598 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 599 |
OpMemberDecorate %16 0 Offset 0 |
| 600 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 601 |
OpMemberDecorate %16 1 Offset 4 |
| 602 |
OpDecorate %16 Block |
| 603 |
OpDecorate %18 DescriptorSet 0 |
| 604 |
OpDecorate %18 Binding 0 |
| 605 |
OpDecorate %23 RelaxedPrecision |
| 606 |
OpDecorate %24 RelaxedPrecision |
| 607 |
OpDecorate %25 RelaxedPrecision |
| 608 |
OpDecorate %26 RelaxedPrecision |
| 609 |
OpDecorate %27 RelaxedPrecision |
| 610 |
OpDecorate %28 RelaxedPrecision |
| 611 |
OpDecorate %29 RelaxedPrecision |
| 612 |
OpDecorate %30 RelaxedPrecision |
| 613 |
OpDecorate %31 RelaxedPrecision |
| 614 |
OpDecorate %34 RelaxedPrecision |
| 615 |
OpDecorate %37 RelaxedPrecision |
| 616 |
OpDecorate %38 RelaxedPrecision |
| 617 |
OpDecorate %40 RelaxedPrecision |
| 618 |
OpDecorate %41 RelaxedPrecision |
| 619 |
OpDecorate %44 RelaxedPrecision |
| 620 |
OpDecorate %45 RelaxedPrecision |
| 621 |
OpDecorate %46 RelaxedPrecision |
| 622 |
OpDecorate %48 RelaxedPrecision |
| 623 |
OpDecorate %55 RelaxedPrecision |
| 624 |
OpDecorate %56 RelaxedPrecision |
| 625 |
OpDecorate %57 RelaxedPrecision |
| 626 |
OpDecorate %58 RelaxedPrecision |
| 627 |
OpDecorate %63 RelaxedPrecision |
| 628 |
OpDecorate %63 Location 0 |
| 629 |
OpDecorate %64 RelaxedPrecision |
| 630 |
OpDecorate %65 RelaxedPrecision |
| 631 |
OpDecorate %67 RelaxedPrecision |
| 632 |
OpDecorate %69 RelaxedPrecision |
| 633 |
OpDecorate %69 Location 0 |
| 634 |
%2 = OpTypeVoid |
| 635 |
%3 = OpTypeFunction %2 |
| 636 |
%6 = OpTypeFloat 32 |
| 637 |
%7 = OpTypeFunction %6 |
| 638 |
%12 = OpTypePointer Function %6 |
| 639 |
%14 = OpConstant %6 0 |
| 640 |
%15 = OpTypeInt 32 0 |
| 641 |
%16 = OpTypeStruct %15 %15 |
| 642 |
%17 = OpTypePointer Uniform %16 |
| 643 |
%18 = OpVariable %17 Uniform |
| 644 |
%19 = OpTypeInt 32 1 |
| 645 |
%20 = OpConstant %19 1 |
| 646 |
%21 = OpTypePointer Uniform %15 |
| 647 |
%35 = OpConstant %19 0 |
| 648 |
%39 = OpConstant %6 10 |
| 649 |
%42 = OpConstant %6 0.5 |
| 650 |
%43 = OpConstant %6 0.699999988 |
| 651 |
%49 = OpConstant %15 0 |
| 652 |
%50 = OpTypeBool |
| 653 |
%54 = OpConstant %6 0.100000001 |
| 654 |
%61 = OpTypeVector %6 4 |
| 655 |
%62 = OpTypePointer Output %61 |
| 656 |
%63 = OpVariable %62 Output |
| 657 |
%66 = OpConstant %6 1 |
| 658 |
%68 = OpTypePointer Input %6 |
| 659 |
%69 = OpVariable %68 Input |
| 660 |
%4 = OpFunction %2 None %3 |
| 661 |
%5 = OpLabel |
| 662 |
%64 = OpFunctionCall %6 %8 |
| 663 |
%65 = OpFunctionCall %6 %10 |
| 664 |
%67 = OpCompositeConstruct %61 %64 %65 %14 %66 |
| 665 |
OpStore %63 %67 |
| 666 |
OpReturn |
| 667 |
OpFunctionEnd |
| 668 |
%8 = OpFunction %6 None %7 |
| 669 |
%9 = OpLabel |
| 670 |
%13 = OpVariable %12 Function |
| 671 |
OpStore %13 %14 |
| 672 |
%22 = OpAccessChain %21 %18 %20 |
| 673 |
%23 = OpLoad %15 %22 |
| 674 |
%24 = OpConvertUToF %6 %23 |
| 675 |
%25 = OpExtInst %6 %1 Log2 %24 |
| 676 |
%26 = OpLoad %6 %13 |
| 677 |
%27 = OpFAdd %6 %26 %25 |
| 678 |
OpStore %13 %27 |
| 679 |
%28 = OpLoad %6 %13 |
| 680 |
%29 = OpLoad %6 %13 |
| 681 |
%30 = OpExtInst %6 %1 Sqrt %29 |
| 682 |
%31 = OpFSub %6 %28 %30 |
| 683 |
OpReturnValue %31 |
| 684 |
OpFunctionEnd |
| 685 |
%10 = OpFunction %6 None %7 |
| 686 |
%11 = OpLabel |
| 687 |
%34 = OpVariable %12 Function |
| 688 |
%36 = OpAccessChain %21 %18 %35 |
| 689 |
%37 = OpLoad %15 %36 |
| 690 |
%38 = OpConvertUToF %6 %37 |
| 691 |
%40 = OpFDiv %6 %38 %39 |
| 692 |
OpStore %34 %40 |
| 693 |
%41 = OpLoad %6 %34 |
| 694 |
%44 = OpExtInst %6 %1 FClamp %41 %42 %43 |
| 695 |
%45 = OpLoad %6 %34 |
| 696 |
%46 = OpFMul %6 %45 %44 |
| 697 |
OpStore %34 %46 |
| 698 |
%47 = OpAccessChain %21 %18 %20 |
| 699 |
%48 = OpLoad %15 %47 |
| 700 |
%51 = OpINotEqual %50 %48 %49 |
| 701 |
OpSelectionMerge %53 None |
| 702 |
OpBranchConditional %51 %52 %53 |
| 703 |
%52 = OpLabel |
| 704 |
%55 = OpLoad %6 %34 |
| 705 |
%56 = OpFSub %6 %55 %54 |
| 706 |
OpStore %34 %56 |
| 707 |
OpBranch %53 |
| 708 |
%53 = OpLabel |
| 709 |
%57 = OpLoad %6 %34 |
| 710 |
%58 = OpExtInst %6 %1 Exp %57 |
| 711 |
OpReturnValue %58 |
| 712 |
OpFunctionEnd |
| 713 |
|
| 714 |
)"; |
| 715 |
constexpr char kDiff[] = R"( ; SPIR-V |
| 716 |
; Version: 1.6 |
| 717 |
; Generator: Khronos SPIR-V Tools Assembler; 0 |
| 718 |
-; Bound: 69 |
| 719 |
+; Bound: 77 |
| 720 |
; Schema: 0 |
| 721 |
OpCapability Shader |
| 722 |
%1 = OpExtInstImport "GLSL.std.450" |
| 723 |
OpMemoryModel Logical GLSL450 |
| 724 |
OpEntryPoint Fragment %4 "main" %63 %68 |
| 725 |
OpExecutionMode %4 OriginUpperLeft |
| 726 |
OpSource ESSL 310 |
| 727 |
OpDecorate %8 RelaxedPrecision |
| 728 |
OpDecorate %10 RelaxedPrecision |
| 729 |
OpDecorate %13 RelaxedPrecision |
| 730 |
OpMemberDecorate %16 0 RelaxedPrecision |
| 731 |
OpMemberDecorate %16 0 Offset 0 |
| 732 |
OpMemberDecorate %16 1 RelaxedPrecision |
| 733 |
OpMemberDecorate %16 1 Offset 4 |
| 734 |
OpDecorate %16 Block |
| 735 |
OpDecorate %18 DescriptorSet 0 |
| 736 |
OpDecorate %18 Binding 0 |
| 737 |
-OpDecorate %23 RelaxedPrecision |
| 738 |
-OpDecorate %30 RelaxedPrecision |
| 739 |
-OpDecorate %31 RelaxedPrecision |
| 740 |
OpDecorate %34 RelaxedPrecision |
| 741 |
OpDecorate %35 RelaxedPrecision |
| 742 |
OpDecorate %36 RelaxedPrecision |
| 743 |
OpDecorate %37 RelaxedPrecision |
| 744 |
OpDecorate %38 RelaxedPrecision |
| 745 |
OpDecorate %39 RelaxedPrecision |
| 746 |
OpDecorate %40 RelaxedPrecision |
| 747 |
OpDecorate %41 RelaxedPrecision |
| 748 |
OpDecorate %42 RelaxedPrecision |
| 749 |
OpDecorate %45 RelaxedPrecision |
| 750 |
OpDecorate %47 RelaxedPrecision |
| 751 |
OpDecorate %48 RelaxedPrecision |
| 752 |
OpDecorate %50 RelaxedPrecision |
| 753 |
OpDecorate %51 RelaxedPrecision |
| 754 |
OpDecorate %54 RelaxedPrecision |
| 755 |
OpDecorate %55 RelaxedPrecision |
| 756 |
OpDecorate %56 RelaxedPrecision |
| 757 |
+OpDecorate %70 RelaxedPrecision |
| 758 |
OpDecorate %57 RelaxedPrecision |
| 759 |
+OpDecorate %75 RelaxedPrecision |
| 760 |
+OpDecorate %76 RelaxedPrecision |
| 761 |
OpDecorate %58 RelaxedPrecision |
| 762 |
OpDecorate %63 RelaxedPrecision |
| 763 |
OpDecorate %63 Location 0 |
| 764 |
OpDecorate %64 RelaxedPrecision |
| 765 |
OpDecorate %65 RelaxedPrecision |
| 766 |
OpDecorate %66 RelaxedPrecision |
| 767 |
OpDecorate %68 RelaxedPrecision |
| 768 |
OpDecorate %68 Location 0 |
| 769 |
%2 = OpTypeVoid |
| 770 |
%3 = OpTypeFunction %2 |
| 771 |
%6 = OpTypeFloat 32 |
| 772 |
%7 = OpTypeFunction %6 |
| 773 |
%12 = OpTypePointer Function %6 |
| 774 |
%14 = OpConstant %6 0 |
| 775 |
%15 = OpTypeInt 32 0 |
| 776 |
%16 = OpTypeStruct %15 %15 |
| 777 |
%17 = OpTypePointer Uniform %16 |
| 778 |
%18 = OpVariable %17 Uniform |
| 779 |
%19 = OpTypeInt 32 1 |
| 780 |
%20 = OpConstant %19 0 |
| 781 |
%21 = OpTypePointer Uniform %15 |
| 782 |
%24 = OpConstant %15 0 |
| 783 |
%25 = OpTypeBool |
| 784 |
%29 = OpConstant %6 1 |
| 785 |
%32 = OpConstant %19 1 |
| 786 |
%49 = OpConstant %6 10 |
| 787 |
%52 = OpConstant %6 0.5 |
| 788 |
+%74 = OpConstant %6 0.100000001 |
| 789 |
%53 = OpConstant %6 0.699999988 |
| 790 |
%61 = OpTypeVector %6 4 |
| 791 |
%62 = OpTypePointer Output %61 |
| 792 |
%63 = OpVariable %62 Output |
| 793 |
%67 = OpTypePointer Input %6 |
| 794 |
%68 = OpVariable %67 Input |
| 795 |
%4 = OpFunction %2 None %3 |
| 796 |
%5 = OpLabel |
| 797 |
%64 = OpFunctionCall %6 %8 |
| 798 |
%65 = OpFunctionCall %6 %10 |
| 799 |
%66 = OpCompositeConstruct %61 %64 %65 %14 %29 |
| 800 |
OpStore %63 %66 |
| 801 |
OpReturn |
| 802 |
OpFunctionEnd |
| 803 |
%8 = OpFunction %6 None %7 |
| 804 |
%9 = OpLabel |
| 805 |
%13 = OpVariable %12 Function |
| 806 |
OpStore %13 %14 |
| 807 |
-%22 = OpAccessChain %21 %18 %20 |
| 808 |
-%23 = OpLoad %15 %22 |
| 809 |
-%26 = OpINotEqual %25 %23 %24 |
| 810 |
-OpSelectionMerge %28 None |
| 811 |
-OpBranchConditional %26 %27 %28 |
| 812 |
-%27 = OpLabel |
| 813 |
-%30 = OpLoad %6 %13 |
| 814 |
-%31 = OpFAdd %6 %30 %29 |
| 815 |
-OpStore %13 %31 |
| 816 |
-OpBranch %28 |
| 817 |
-%28 = OpLabel |
| 818 |
%33 = OpAccessChain %21 %18 %32 |
| 819 |
%34 = OpLoad %15 %33 |
| 820 |
%35 = OpConvertUToF %6 %34 |
| 821 |
%36 = OpExtInst %6 %1 Log2 %35 |
| 822 |
%37 = OpLoad %6 %13 |
| 823 |
%38 = OpFAdd %6 %37 %36 |
| 824 |
OpStore %13 %38 |
| 825 |
%39 = OpLoad %6 %13 |
| 826 |
%40 = OpLoad %6 %13 |
| 827 |
%41 = OpExtInst %6 %1 Sqrt %40 |
| 828 |
%42 = OpFSub %6 %39 %41 |
| 829 |
OpReturnValue %42 |
| 830 |
OpFunctionEnd |
| 831 |
%10 = OpFunction %6 None %7 |
| 832 |
%11 = OpLabel |
| 833 |
%45 = OpVariable %12 Function |
| 834 |
%46 = OpAccessChain %21 %18 %20 |
| 835 |
%47 = OpLoad %15 %46 |
| 836 |
%48 = OpConvertUToF %6 %47 |
| 837 |
%50 = OpFDiv %6 %48 %49 |
| 838 |
OpStore %45 %50 |
| 839 |
%51 = OpLoad %6 %45 |
| 840 |
%54 = OpExtInst %6 %1 FClamp %51 %52 %53 |
| 841 |
%55 = OpLoad %6 %45 |
| 842 |
%56 = OpFMul %6 %55 %54 |
| 843 |
OpStore %45 %56 |
| 844 |
+%69 = OpAccessChain %21 %18 %32 |
| 845 |
+%70 = OpLoad %15 %69 |
| 846 |
+%71 = OpINotEqual %25 %70 %24 |
| 847 |
+OpSelectionMerge %73 None |
| 848 |
+OpBranchConditional %71 %72 %73 |
| 849 |
+%72 = OpLabel |
| 850 |
%57 = OpLoad %6 %45 |
| 851 |
+%75 = OpFSub %6 %57 %74 |
| 852 |
+OpStore %45 %75 |
| 853 |
+OpBranch %73 |
| 854 |
+%73 = OpLabel |
| 855 |
+%76 = OpLoad %6 %45 |
| 856 |
-%58 = OpExtInst %6 %1 Exp %57 |
| 857 |
+%58 = OpExtInst %6 %1 Exp %76 |
| 858 |
OpReturnValue %58 |
| 859 |
OpFunctionEnd |
| 860 |
)"; |
| 861 |
Options options; |
| 862 |
DoStringDiffTest(kSrcNoDebug, kDstNoDebug, kDiff, options); |
| 863 |
} |
| 864 |
|
| 865 |
} // namespace |
| 866 |
} // namespace diff |
| 867 |
} // namespace spvtools |