test: Add a test case for tint:1321

It's surprising that the fuzzers didn't find this, but I've confirmed that at least one of the fuzzers will fail with this case.
By adding a e2e test case, this will be used as a seed for the fuzzer corpus.

Bug: tint:1321
Change-Id: Ibf4bfa50bf376ae4cba401dfc31a2498fa3b9eec
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/70982
Reviewed-by: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
diff --git a/test/bug/tint/1321.wgsl b/test/bug/tint/1321.wgsl
new file mode 100644
index 0000000..0c2d7ec
--- /dev/null
+++ b/test/bug/tint/1321.wgsl
@@ -0,0 +1,12 @@
+fn foo() -> i32 {
+  return 1;
+}
+
+[[stage(fragment)]]
+fn main() {
+  var arr = array<f32, 4>();
+  for (let a = &arr[foo()]; ;) {
+    let x = *a;
+    break;
+  }
+}
diff --git a/test/bug/tint/1321.wgsl.expected.hlsl b/test/bug/tint/1321.wgsl.expected.hlsl
new file mode 100644
index 0000000..fed870b
--- /dev/null
+++ b/test/bug/tint/1321.wgsl.expected.hlsl
@@ -0,0 +1,15 @@
+int foo() {
+  return 1;
+}
+
+void main() {
+  float arr[4] = (float[4])0;
+  const int a_save = foo();
+  {
+    for(; ; ) {
+      const float x = arr[a_save];
+      break;
+    }
+  }
+  return;
+}
diff --git a/test/bug/tint/1321.wgsl.expected.msl b/test/bug/tint/1321.wgsl.expected.msl
new file mode 100644
index 0000000..fc79791
--- /dev/null
+++ b/test/bug/tint/1321.wgsl.expected.msl
@@ -0,0 +1,21 @@
+#include <metal_stdlib>
+
+using namespace metal;
+struct tint_array_wrapper {
+  float arr[4];
+};
+
+int foo() {
+  return 1;
+}
+
+fragment void tint_symbol() {
+  tint_array_wrapper arr = {.arr={}};
+  int const a_save = foo();
+  for(; ; ) {
+    float const x = arr.arr[a_save];
+    break;
+  }
+  return;
+}
+
diff --git a/test/bug/tint/1321.wgsl.expected.spvasm b/test/bug/tint/1321.wgsl.expected.spvasm
new file mode 100644
index 0000000..0f7e62d
--- /dev/null
+++ b/test/bug/tint/1321.wgsl.expected.spvasm
@@ -0,0 +1,47 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 25
+; Schema: 0
+               OpCapability Shader
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Fragment %main "main"
+               OpExecutionMode %main OriginUpperLeft
+               OpName %foo "foo"
+               OpName %main "main"
+               OpName %arr "arr"
+               OpDecorate %_arr_float_uint_4 ArrayStride 4
+        %int = OpTypeInt 32 1
+          %1 = OpTypeFunction %int
+      %int_1 = OpConstant %int 1
+       %void = OpTypeVoid
+          %6 = OpTypeFunction %void
+      %float = OpTypeFloat 32
+       %uint = OpTypeInt 32 0
+     %uint_4 = OpConstant %uint 4
+%_arr_float_uint_4 = OpTypeArray %float %uint_4
+         %14 = OpConstantNull %_arr_float_uint_4
+%_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4
+%_ptr_Function_float = OpTypePointer Function %float
+        %foo = OpFunction %int None %1
+          %4 = OpLabel
+               OpReturnValue %int_1
+               OpFunctionEnd
+       %main = OpFunction %void None %6
+          %9 = OpLabel
+        %arr = OpVariable %_ptr_Function__arr_float_uint_4 Function %14
+               OpStore %arr %14
+         %17 = OpFunctionCall %int %foo
+               OpBranch %18
+         %18 = OpLabel
+               OpLoopMerge %19 %20 None
+               OpBranch %21
+         %21 = OpLabel
+         %23 = OpAccessChain %_ptr_Function_float %arr %17
+         %24 = OpLoad %float %23
+               OpBranch %19
+         %20 = OpLabel
+               OpBranch %18
+         %19 = OpLabel
+               OpReturn
+               OpFunctionEnd
diff --git a/test/bug/tint/1321.wgsl.expected.wgsl b/test/bug/tint/1321.wgsl.expected.wgsl
new file mode 100644
index 0000000..8f7d2f7
--- /dev/null
+++ b/test/bug/tint/1321.wgsl.expected.wgsl
@@ -0,0 +1,12 @@
+fn foo() -> i32 {
+  return 1;
+}
+
+[[stage(fragment)]]
+fn main() {
+  var arr = array<f32, 4>();
+  for(let a = &(arr[foo()]); ; ) {
+    let x = *(a);
+    break;
+  }
+}