[hlsl] Use PreventInfiniteLoops transform

This hardens potentially infinite loops to prevent them from being
exploited to circumvent bounds checks.

Emit return statements for `unreachable` instructions that terminate
function bodies, as now DXC believes that they might be reachable.

Bug: 380090814
Change-Id: I66bcfbe9b0f222b2f67195130555f34ddad94c13
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/217335
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: James Price <jrprice@google.com>
diff --git a/src/tint/lang/hlsl/writer/loop_test.cc b/src/tint/lang/hlsl/writer/loop_test.cc
index 33db413..b6f301c 100644
--- a/src/tint/lang/hlsl/writer/loop_test.cc
+++ b/src/tint/lang/hlsl/writer/loop_test.cc
@@ -48,7 +48,11 @@
 [numthreads(1, 1, 1)]
 void a() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       break;
     }
   }
@@ -72,8 +76,16 @@
 [numthreads(1, 1, 1)]
 void a() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (true) { break; }
       }
       continue;
@@ -103,9 +115,17 @@
 [numthreads(1, 1, 1)]
 void a() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v = true;
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (v) { break; }
       }
       continue;
@@ -136,9 +156,17 @@
 [numthreads(1, 1, 1)]
 void a() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     bool v = true;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (v) { break; }
       }
       continue;
@@ -149,5 +177,37 @@
 )");
 }
 
+TEST_F(HlslWriterTest, Loop_UnconditionalReturn_NonVoid) {
+    auto* func = b.Function("a", ty.i32());
+
+    b.Append(func->Block(), [&] {
+        auto* l = b.Loop();
+        b.Append(l->Body(), [&] { b.Return(func, 1_i); });
+        b.Unreachable();
+    });
+
+    ASSERT_TRUE(Generate()) << err_ << output_.hlsl;
+    EXPECT_EQ(output_.hlsl, R"(
+int a() {
+  {
+    uint2 tint_loop_idx = (0u).xx;
+    while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
+      return int(1);
+    }
+  }
+  /* unreachable */
+  return int(0);
+}
+
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+}
+
+)");
+}
+
 }  // namespace
 }  // namespace tint::hlsl::writer
diff --git a/src/tint/lang/hlsl/writer/printer/printer.cc b/src/tint/lang/hlsl/writer/printer/printer.cc
index b482928..80b9f98 100644
--- a/src/tint/lang/hlsl/writer/printer/printer.cc
+++ b/src/tint/lang/hlsl/writer/printer/printer.cc
@@ -432,7 +432,20 @@
     }
 
     /// Emit an unreachable instruction
-    void EmitUnreachable() { Line() << "/* unreachable */"; }
+    void EmitUnreachable() {
+        Line() << "/* unreachable */";
+        if (current_block_ == current_function_->Block() &&
+            !current_function_->ReturnType()->Is<core::type::Void>()) {
+            // If this is the end of a non-void function, emit a return statement to avoid DXC
+            // errors due to -Wreturn-type + -Werror (see crbug.com/378517038).
+            // TODO(381541325): Remove this once these reachable-unreachables are replaced.
+            auto out = Line();
+            out << "return ";
+            EmitZeroValue(out, current_function_->ReturnType());
+            out << ";";
+            return;
+        }
+    }
 
     void EmitContinue() {
         if (emit_continuing_) {
diff --git a/src/tint/lang/hlsl/writer/raise/raise.cc b/src/tint/lang/hlsl/writer/raise/raise.cc
index eae4c7a..7e9c103 100644
--- a/src/tint/lang/hlsl/writer/raise/raise.cc
+++ b/src/tint/lang/hlsl/writer/raise/raise.cc
@@ -39,6 +39,7 @@
 #include "src/tint/lang/core/ir/transform/demote_to_helper.h"
 #include "src/tint/lang/core/ir/transform/direct_variable_access.h"
 #include "src/tint/lang/core/ir/transform/multiplanar_external_texture.h"
+#include "src/tint/lang/core/ir/transform/prevent_infinite_loops.h"
 #include "src/tint/lang/core/ir/transform/remove_continue_in_switch.h"
 #include "src/tint/lang/core/ir/transform/remove_terminator_args.h"
 #include "src/tint/lang/core/ir/transform/rename_conflicts.h"
@@ -80,6 +81,10 @@
     RUN_TRANSFORM(core::ir::transform::BindingRemapper, module, remapper_data);
     RUN_TRANSFORM(core::ir::transform::MultiplanarExternalTexture, module, multiplanar_map);
 
+    if (!options.disable_robustness) {
+        RUN_TRANSFORM(core::ir::transform::PreventInfiniteLoops, module);
+    }
+
     {
         core::ir::transform::BinaryPolyfillConfig binary_polyfills{};
         binary_polyfills.int_div_mod = !options.disable_polyfill_integer_div_mod;
diff --git a/test/tint/bug/chromium/1403752.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/chromium/1403752.wgsl.expected.ir.dxc.hlsl
index fc95e33..7f6a593 100644
--- a/test/tint/bug/chromium/1403752.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/chromium/1403752.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void d() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/chromium/1403752.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/chromium/1403752.wgsl.expected.ir.fxc.hlsl
index fc95e33..7f6a593 100644
--- a/test/tint/bug/chromium/1403752.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/chromium/1403752.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void d() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/chromium/1449538.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/chromium/1449538.wgsl.expected.ir.dxc.hlsl
index 0c5295f..e1fcfa9 100644
--- a/test/tint/bug/chromium/1449538.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/chromium/1449538.wgsl.expected.ir.dxc.hlsl
@@ -1,97 +1,161 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i0520 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_1 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_1;
+        uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_1);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i0520 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_2 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_2;
+        uint tint_carry_2 = uint((tint_low_inc_2 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_2);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_3 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_3;
+        uint tint_carry_3 = uint((tint_low_inc_3 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_3);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_4 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_4;
+        uint tint_carry_4 = uint((tint_low_inc_4 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_4);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i60 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_5 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_5;
+        uint tint_carry_5 = uint((tint_low_inc_5 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_5);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_6 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_6;
+        uint tint_carry_6 = uint((tint_low_inc_6 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_6);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i60 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_7 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_7;
+        uint tint_carry_7 = uint((tint_low_inc_7 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_7);
       }
       continue;
     }
diff --git a/test/tint/bug/chromium/1449538.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/chromium/1449538.wgsl.expected.ir.fxc.hlsl
index 0c5295f..e1fcfa9 100644
--- a/test/tint/bug/chromium/1449538.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/chromium/1449538.wgsl.expected.ir.fxc.hlsl
@@ -1,97 +1,161 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i0520 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_1 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_1;
+        uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_1);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i0520 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_2 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_2;
+        uint tint_carry_2 = uint((tint_low_inc_2 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_2);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_3 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_3;
+        uint tint_carry_3 = uint((tint_low_inc_3 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_3);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_4 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_4;
+        uint tint_carry_4 = uint((tint_low_inc_4 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_4);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i60 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_5 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_5;
+        uint tint_carry_5 = uint((tint_low_inc_5 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_5);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i62 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_6 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_6;
+        uint tint_carry_6 = uint((tint_low_inc_6 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_6);
       }
       continue;
     }
   }
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i60 = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc_7 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_7;
+        uint tint_carry_7 = uint((tint_low_inc_7 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_7);
       }
       continue;
     }
diff --git a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.dxc.hlsl
index 2e9887e..4ded95d 100644
--- a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.dxc.hlsl
@@ -14,7 +14,11 @@
   float3 random = randomTexture.Sample(tint_symbol, vUV).xyz;
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
@@ -41,12 +45,20 @@
       if (v_2) {
         i = (i + int(1));
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         }
         continue;
       }
       float sampleDepth = 0.0f;
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.fxc.hlsl
index 2e9887e..4ded95d 100644
--- a/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/fxc/gradient_in_varying_loop/1112.wgsl.expected.ir.fxc.hlsl
@@ -14,7 +14,11 @@
   float3 random = randomTexture.Sample(tint_symbol, vUV).xyz;
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
@@ -41,12 +45,20 @@
       if (v_2) {
         i = (i + int(1));
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         }
         continue;
       }
       float sampleDepth = 0.0f;
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1064.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1064.wgsl.expected.ir.dxc.hlsl
index 7730ddd..86430b6 100644
--- a/test/tint/bug/tint/1064.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1064.wgsl.expected.ir.dxc.hlsl
@@ -1,12 +1,20 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (false) { break; }
       }
       continue;
diff --git a/test/tint/bug/tint/1064.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1064.wgsl.expected.ir.fxc.hlsl
index 7730ddd..86430b6 100644
--- a/test/tint/bug/tint/1064.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1064.wgsl.expected.ir.fxc.hlsl
@@ -1,12 +1,20 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (false) { break; }
       }
       continue;
diff --git a/test/tint/bug/tint/1081.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1081.wgsl.expected.ir.dxc.hlsl
index 37bb42a..dee4ed5 100644
--- a/test/tint/bug/tint/1081.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1081.wgsl.expected.ir.dxc.hlsl
@@ -17,12 +17,20 @@
 int main_inner(int3 x) {
   int y = x.x;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int r = f(y);
       if ((r == int(0))) {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1081.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1081.wgsl.expected.ir.fxc.hlsl
index 55dd5b6..0386d66 100644
--- a/test/tint/bug/tint/1081.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1081.wgsl.expected.ir.fxc.hlsl
@@ -18,12 +18,20 @@
 int main_inner(int3 x) {
   int y = x.x;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int r = f(y);
       if ((r == int(0))) {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1321.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1321.wgsl.expected.ir.dxc.hlsl
index 13e6cc6..8fd5cbf 100644
--- a/test/tint/bug/tint/1321.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1321.wgsl.expected.ir.dxc.hlsl
@@ -6,8 +6,12 @@
 void main() {
   float arr[4] = (float[4])0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v = min(uint(foo()), 3u);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       float x = arr[v];
       break;
     }
diff --git a/test/tint/bug/tint/1321.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1321.wgsl.expected.ir.fxc.hlsl
index 13e6cc6..8fd5cbf 100644
--- a/test/tint/bug/tint/1321.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1321.wgsl.expected.ir.fxc.hlsl
@@ -6,8 +6,12 @@
 void main() {
   float arr[4] = (float[4])0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v = min(uint(foo()), 3u);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       float x = arr[v];
       break;
     }
diff --git a/test/tint/bug/tint/1474-a.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1474-a.wgsl.expected.ir.dxc.hlsl
index 208c6aa..38d7c6c 100644
--- a/test/tint/bug/tint/1474-a.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1474-a.wgsl.expected.ir.dxc.hlsl
@@ -2,7 +2,11 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (true) {
       } else {
         break;
@@ -13,6 +17,10 @@
         return;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1474-a.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1474-a.wgsl.expected.ir.fxc.hlsl
index 208c6aa..38d7c6c 100644
--- a/test/tint/bug/tint/1474-a.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1474-a.wgsl.expected.ir.fxc.hlsl
@@ -2,7 +2,11 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (true) {
       } else {
         break;
@@ -13,6 +17,10 @@
         return;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1538.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1538.wgsl.expected.ir.dxc.hlsl
index f32bad5..e0748a7 100644
--- a/test/tint/bug/tint/1538.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1538.wgsl.expected.ir.dxc.hlsl
@@ -6,7 +6,11 @@
 
 int f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       g();
       break;
     }
@@ -18,13 +22,21 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((buf.Load(0u) == 0u)) {
         break;
       }
       int s = f();
       buf.Store(0u, 0u);
       {
+        uint tint_low_inc_1 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_1;
+        uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_1);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1538.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1538.wgsl.expected.ir.fxc.hlsl
index f32bad5..e0748a7 100644
--- a/test/tint/bug/tint/1538.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1538.wgsl.expected.ir.fxc.hlsl
@@ -6,7 +6,11 @@
 
 int f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       g();
       break;
     }
@@ -18,13 +22,21 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((buf.Load(0u) == 0u)) {
         break;
       }
       int s = f();
       buf.Store(0u, 0u);
       {
+        uint tint_low_inc_1 = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc_1;
+        uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry_1);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1557.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1557.wgsl.expected.ir.dxc.hlsl
index 6c25fae..4969303 100644
--- a/test/tint/bug/tint/1557.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1557.wgsl.expected.ir.dxc.hlsl
@@ -9,13 +9,21 @@
 void g() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((j >= int(1))) {
         break;
       }
       j = (j + int(1));
       int k = f();
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/1604.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1604.wgsl.expected.ir.dxc.hlsl
index 6aa4b0f..ea362bd 100644
--- a/test/tint/bug/tint/1604.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1604.wgsl.expected.ir.dxc.hlsl
@@ -8,7 +8,11 @@
     case int(0):
     {
       {
+        uint2 tint_loop_idx = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx == (4294967295u).xx))) {
+            break;
+          }
           return;
         }
       }
diff --git a/test/tint/bug/tint/1604.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1604.wgsl.expected.ir.fxc.hlsl
index 6aa4b0f..ea362bd 100644
--- a/test/tint/bug/tint/1604.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1604.wgsl.expected.ir.fxc.hlsl
@@ -8,7 +8,11 @@
     case int(0):
     {
       {
+        uint2 tint_loop_idx = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx == (4294967295u).xx))) {
+            break;
+          }
           return;
         }
       }
diff --git a/test/tint/bug/tint/1605.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/1605.wgsl.expected.ir.dxc.hlsl
index 04cdf4e..9eaf560 100644
--- a/test/tint/bug/tint/1605.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/1605.wgsl.expected.ir.dxc.hlsl
@@ -4,15 +4,23 @@
 };
 bool func_3() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < asint(b[0u].x))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(-1);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j == int(1))) {
           } else {
             break;
@@ -21,6 +29,10 @@
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/bug/tint/1605.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/1605.wgsl.expected.ir.fxc.hlsl
index 04cdf4e..9eaf560 100644
--- a/test/tint/bug/tint/1605.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/1605.wgsl.expected.ir.fxc.hlsl
@@ -4,15 +4,23 @@
 };
 bool func_3() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < asint(b[0u].x))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(-1);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j == int(1))) {
           } else {
             break;
@@ -21,6 +29,10 @@
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/bug/tint/2039.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/2039.wgsl.expected.ir.dxc.hlsl
index 5556802..c9b52b1 100644
--- a/test/tint/bug/tint/2039.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/2039.wgsl.expected.ir.dxc.hlsl
@@ -3,7 +3,11 @@
 void main() {
   uint tint_symbol = 0u;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(int(2)) {
         case int(1):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           if (true) { break; }
         }
         continue;
       }
       tint_symbol = (tint_symbol + 1u);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (true) { break; }
       }
       continue;
diff --git a/test/tint/bug/tint/2039.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/2039.wgsl.expected.ir.fxc.hlsl
index 5556802..c9b52b1 100644
--- a/test/tint/bug/tint/2039.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/2039.wgsl.expected.ir.fxc.hlsl
@@ -3,7 +3,11 @@
 void main() {
   uint tint_symbol = 0u;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(int(2)) {
         case int(1):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           if (true) { break; }
         }
         continue;
       }
       tint_symbol = (tint_symbol + 1u);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if (true) { break; }
       }
       continue;
diff --git a/test/tint/bug/tint/2201.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/2201.wgsl.expected.ir.dxc.hlsl
index c219a60..c594136 100644
--- a/test/tint/bug/tint/2201.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/2201.wgsl.expected.ir.dxc.hlsl
@@ -6,7 +6,11 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (true) {
         break;
       } else {
diff --git a/test/tint/bug/tint/2201.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/2201.wgsl.expected.ir.fxc.hlsl
index c219a60..c594136 100644
--- a/test/tint/bug/tint/2201.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/2201.wgsl.expected.ir.fxc.hlsl
@@ -6,7 +6,11 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (true) {
         break;
       } else {
diff --git a/test/tint/bug/tint/2202.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/2202.wgsl.expected.ir.dxc.hlsl
index 251252b..0a53289 100644
--- a/test/tint/bug/tint/2202.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/2202.wgsl.expected.ir.dxc.hlsl
@@ -6,9 +6,17 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           return;
         }
       }
diff --git a/test/tint/bug/tint/2202.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/2202.wgsl.expected.ir.fxc.hlsl
index 251252b..0a53289 100644
--- a/test/tint/bug/tint/2202.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/2202.wgsl.expected.ir.fxc.hlsl
@@ -6,9 +6,17 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           return;
         }
       }
diff --git a/test/tint/bug/tint/221.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/221.wgsl.expected.ir.dxc.hlsl
index 9588e5e..0a24cbc 100644
--- a/test/tint/bug/tint/221.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/221.wgsl.expected.ir.dxc.hlsl
@@ -9,13 +9,21 @@
 void main() {
   uint i = 0u;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i >= b.Load(0u))) {
         break;
       }
       uint v_1 = (min(i, 49u) * 4u);
       if ((tint_mod_u32(i, 2u) == 0u)) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           b.Store((4u + v_1), (b.Load((4u + v_1)) * 2u));
           i = (i + 1u);
         }
@@ -23,6 +31,10 @@
       }
       b.Store((4u + v_1), 0u);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         b.Store((4u + v_1), (b.Load((4u + v_1)) * 2u));
         i = (i + 1u);
       }
diff --git a/test/tint/bug/tint/221.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/221.wgsl.expected.ir.fxc.hlsl
index 9588e5e..0a24cbc 100644
--- a/test/tint/bug/tint/221.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/221.wgsl.expected.ir.fxc.hlsl
@@ -9,13 +9,21 @@
 void main() {
   uint i = 0u;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i >= b.Load(0u))) {
         break;
       }
       uint v_1 = (min(i, 49u) * 4u);
       if ((tint_mod_u32(i, 2u) == 0u)) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           b.Store((4u + v_1), (b.Load((4u + v_1)) * 2u));
           i = (i + 1u);
         }
@@ -23,6 +31,10 @@
       }
       b.Store((4u + v_1), 0u);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         b.Store((4u + v_1), (b.Load((4u + v_1)) * 2u));
         i = (i + 1u);
       }
diff --git a/test/tint/bug/tint/349291130.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/349291130.wgsl.expected.ir.dxc.hlsl
index 1b51fbe..c1c4b06 100644
--- a/test/tint/bug/tint/349291130.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/349291130.wgsl.expected.ir.dxc.hlsl
@@ -3,15 +3,23 @@
 [numthreads(6, 1, 1)]
 void e() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint3 v = (0u).xxx;
     tint_symbol.GetDimensions(0u, v.x, v.y, v.z);
     uint level = v.z;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((level > 0u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/349291130.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/349291130.wgsl.expected.ir.fxc.hlsl
index 1b51fbe..c1c4b06 100644
--- a/test/tint/bug/tint/349291130.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/349291130.wgsl.expected.ir.fxc.hlsl
@@ -3,15 +3,23 @@
 [numthreads(6, 1, 1)]
 void e() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint3 v = (0u).xxx;
     tint_symbol.GetDimensions(0u, v.x, v.y, v.z);
     uint level = v.z;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((level > 0u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/354627692.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/354627692.wgsl.expected.ir.dxc.hlsl
index 2c3ea45..2d8f069 100644
--- a/test/tint/bug/tint/354627692.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/354627692.wgsl.expected.ir.dxc.hlsl
@@ -4,10 +4,22 @@
 void main() {
   int i = asint(buffer.Load(0u));
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             if ((i > int(5))) {
               i = (i * int(2));
               break;
diff --git a/test/tint/bug/tint/354627692.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/354627692.wgsl.expected.ir.fxc.hlsl
index 2c3ea45..2d8f069 100644
--- a/test/tint/bug/tint/354627692.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/354627692.wgsl.expected.ir.fxc.hlsl
@@ -4,10 +4,22 @@
 void main() {
   int i = asint(buffer.Load(0u));
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             if ((i > int(5))) {
               i = (i * int(2));
               break;
diff --git a/test/tint/bug/tint/379127084.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/379127084.wgsl.expected.ir.dxc.hlsl
index f0f1970..e484536 100644
--- a/test/tint/bug/tint/379127084.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/379127084.wgsl.expected.ir.dxc.hlsl
@@ -45,7 +45,11 @@
   float _60_n = 1.0f;
   int _61_o = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v_4 = 0u;
       _storage1.GetDimensions(v_4);
       if ((_61_o < asint(_storage1.Load((20u + (min(shadingSsboIndex, ((v_4 / 128u) - 1u)) * 128u)))))) {
@@ -76,7 +80,11 @@
         float4 _71_g = (0.0f).xxxx;
         int _72_h = int(0);
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             float _73_i = ((float(_72_h) + 0.5f) * 0.25f);
             float v_6 = float(_67_p.x);
             float4 _74_j = noiseSampler_1_Texture.SampleBias(noiseSampler_1_Sampler, float2(v_6, float(_73_i)), clamp(-0.47499999403953552246f, -16.0f, 15.9899997711181640625f));
@@ -105,6 +113,10 @@
             float _skTemp13 = lerp(_81_q, _82_r, _69_e.y);
             _71_g[min(uint(_72_h), 3u)] = _skTemp13;
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               _72_h = (_72_h + int(1));
               if ((_72_h >= int(4))) { break; }
             }
@@ -124,6 +136,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         _61_o = (_61_o + int(1));
       }
       continue;
diff --git a/test/tint/bug/tint/379127084.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/379127084.wgsl.expected.ir.fxc.hlsl
index f4209da..762bda0 100644
--- a/test/tint/bug/tint/379127084.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/379127084.wgsl.expected.ir.fxc.hlsl
@@ -45,7 +45,11 @@
   float _60_n = 1.0f;
   int _61_o = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v_4 = 0u;
       _storage1.GetDimensions(v_4);
       if ((_61_o < asint(_storage1.Load((20u + (min(shadingSsboIndex, ((v_4 / 128u) - 1u)) * 128u)))))) {
@@ -76,7 +80,11 @@
         float4 _71_g = (0.0f).xxxx;
         int _72_h = int(0);
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             float _73_i = ((float(_72_h) + 0.5f) * 0.25f);
             float v_6 = float(_67_p.x);
             float4 _74_j = noiseSampler_1_Texture.SampleBias(noiseSampler_1_Sampler, float2(v_6, float(_73_i)), clamp(-0.47499999403953552246f, -16.0f, 15.9899997711181640625f));
@@ -107,6 +115,10 @@
             float4 v_11 = _72_h.xxxx;
             _71_g = (((v_11 == float4(int(0), int(1), int(2), int(3)))) ? (_skTemp13.xxxx) : (v_10));
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               _72_h = (_72_h + int(1));
               if ((_72_h >= int(4))) { break; }
             }
@@ -126,6 +138,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         _61_o = (_61_o + int(1));
       }
       continue;
diff --git a/test/tint/bug/tint/379684039-2.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/379684039-2.wgsl.expected.ir.dxc.hlsl
index 3bc343a..7711b40 100644
--- a/test/tint/bug/tint/379684039-2.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/379684039-2.wgsl.expected.ir.dxc.hlsl
@@ -4,13 +4,21 @@
 void main() {
   int2 vec = (int(0)).xx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v = 0u;
       _storage.GetDimensions(v);
       if ((vec.y >= asint(_storage.Load((116u + (min(idx, ((v / 128u) - 1u)) * 128u)))))) {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/379684039-2.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/379684039-2.wgsl.expected.ir.fxc.hlsl
index 3bc343a..7711b40 100644
--- a/test/tint/bug/tint/379684039-2.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/379684039-2.wgsl.expected.ir.fxc.hlsl
@@ -4,13 +4,21 @@
 void main() {
   int2 vec = (int(0)).xx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v = 0u;
       _storage.GetDimensions(v);
       if ((vec.y >= asint(_storage.Load((116u + (min(idx, ((v / 128u) - 1u)) * 128u)))))) {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/379684039.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/379684039.wgsl.expected.ir.dxc.hlsl
index 13bf43c..5c03d75 100644
--- a/test/tint/bug/tint/379684039.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/379684039.wgsl.expected.ir.dxc.hlsl
@@ -3,7 +3,11 @@
 void main() {
   int2 vec = (int(0)).xx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((vec.y >= asint(_storage.Load(4u)))) {
         break;
       }
@@ -11,6 +15,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/379684039.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/379684039.wgsl.expected.ir.fxc.hlsl
index 13bf43c..5c03d75 100644
--- a/test/tint/bug/tint/379684039.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/379684039.wgsl.expected.ir.fxc.hlsl
@@ -3,7 +3,11 @@
 void main() {
   int2 vec = (int(0)).xx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((vec.y >= asint(_storage.Load(4u)))) {
         break;
       }
@@ -11,6 +15,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/534.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/534.wgsl.expected.ir.dxc.hlsl
index a9adb48..8024b5f 100644
--- a/test/tint/bug/tint/534.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/534.wgsl.expected.ir.dxc.hlsl
@@ -46,8 +46,12 @@
   uint4 srcColorBits = (0u).xxxx;
   uint4 dstColorBits = tint_v4f32_to_v4u32(dstColor);
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint i = 0u;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < uniforms[0u].w)) {
       } else {
         break;
@@ -62,6 +66,10 @@
       }
       success = v_12;
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + 1u);
       }
       continue;
diff --git a/test/tint/bug/tint/534.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/534.wgsl.expected.ir.fxc.hlsl
index 3fa8342..84d74d8 100644
--- a/test/tint/bug/tint/534.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/534.wgsl.expected.ir.fxc.hlsl
@@ -46,8 +46,12 @@
   uint4 srcColorBits = (0u).xxxx;
   uint4 dstColorBits = tint_v4f32_to_v4u32(dstColor);
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint i = 0u;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < uniforms[0u].w)) {
       } else {
         break;
@@ -64,6 +68,10 @@
       }
       success = v_14;
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + 1u);
       }
       continue;
diff --git a/test/tint/bug/tint/942.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/942.wgsl.expected.ir.dxc.hlsl
index 165210c..f9f3939 100644
--- a/test/tint/bug/tint/942.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/942.wgsl.expected.ir.dxc.hlsl
@@ -114,8 +114,12 @@
           if (v_10) {
             float3 acc = (0.0f).xxx;
             {
+              uint2 tint_loop_idx = (0u).xx;
               uint f = 0u;
               while(true) {
+                if (all((tint_loop_idx == (4294967295u).xx))) {
+                  break;
+                }
                 if ((f < params[0u].x)) {
                 } else {
                   break;
@@ -127,6 +131,10 @@
                 uint v_14 = min(i, 255u);
                 acc = (v_11 + (v_12 * tile[v_13][v_14]));
                 {
+                  uint tint_low_inc = (tint_loop_idx.x + 1u);
+                  tint_loop_idx.x = tint_low_inc;
+                  uint tint_carry = uint((tint_low_inc == 0u));
+                  tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
                   f = (f + 1u);
                 }
                 continue;
diff --git a/test/tint/bug/tint/942.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/942.wgsl.expected.ir.fxc.hlsl
index 165210c..f9f3939 100644
--- a/test/tint/bug/tint/942.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/942.wgsl.expected.ir.fxc.hlsl
@@ -114,8 +114,12 @@
           if (v_10) {
             float3 acc = (0.0f).xxx;
             {
+              uint2 tint_loop_idx = (0u).xx;
               uint f = 0u;
               while(true) {
+                if (all((tint_loop_idx == (4294967295u).xx))) {
+                  break;
+                }
                 if ((f < params[0u].x)) {
                 } else {
                   break;
@@ -127,6 +131,10 @@
                 uint v_14 = min(i, 255u);
                 acc = (v_11 + (v_12 * tile[v_13][v_14]));
                 {
+                  uint tint_low_inc = (tint_loop_idx.x + 1u);
+                  tint_loop_idx.x = tint_low_inc;
+                  uint tint_carry = uint((tint_low_inc == 0u));
+                  tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
                   f = (f + 1u);
                 }
                 continue;
diff --git a/test/tint/bug/tint/948.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/948.wgsl.expected.ir.dxc.hlsl
index c8230dc..d49533e 100644
--- a/test/tint/bug/tint/948.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/948.wgsl.expected.ir.dxc.hlsl
@@ -86,7 +86,11 @@
   stageUnits = ((1.0f).xx / x_111);
   i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x_122 = i;
       if ((x_122 < int(2))) {
       } else {
@@ -127,7 +131,11 @@
         mt = ((x_181 * x_184) - ((((v_2 < 0.0f)) ? (ceil(v_2)) : (floor(v_2))) * 1.0f));
         f = 0.0f;
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             float x_193 = f;
             if ((x_193 < 8.0f)) {
             } else {
@@ -146,6 +154,10 @@
             float4 x_217 = (0.0f).xxxx;
             animationData = x_217;
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               float x_218 = f;
               f = (x_218 + 1.0f);
             }
@@ -199,6 +211,10 @@
         color = float4(x_298.x, x_298.y, x_298.z, x_299);
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_304 = i;
         i = (x_304 + int(1));
       }
diff --git a/test/tint/bug/tint/948.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/948.wgsl.expected.ir.fxc.hlsl
index c8230dc..d49533e 100644
--- a/test/tint/bug/tint/948.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/948.wgsl.expected.ir.fxc.hlsl
@@ -86,7 +86,11 @@
   stageUnits = ((1.0f).xx / x_111);
   i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x_122 = i;
       if ((x_122 < int(2))) {
       } else {
@@ -127,7 +131,11 @@
         mt = ((x_181 * x_184) - ((((v_2 < 0.0f)) ? (ceil(v_2)) : (floor(v_2))) * 1.0f));
         f = 0.0f;
         {
+          uint2 tint_loop_idx_1 = (0u).xx;
           while(true) {
+            if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+              break;
+            }
             float x_193 = f;
             if ((x_193 < 8.0f)) {
             } else {
@@ -146,6 +154,10 @@
             float4 x_217 = (0.0f).xxxx;
             animationData = x_217;
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               float x_218 = f;
               f = (x_218 + 1.0f);
             }
@@ -199,6 +211,10 @@
         color = float4(x_298.x, x_298.y, x_298.z, x_299);
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_304 = i;
         i = (x_304 + int(1));
       }
diff --git a/test/tint/bug/tint/949.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/949.wgsl.expected.ir.dxc.hlsl
index b03e9f5..495ca28 100644
--- a/test/tint/bug/tint/949.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/949.wgsl.expected.ir.dxc.hlsl
@@ -299,7 +299,11 @@
   currSampledHeight = 1.0f;
   i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x_388 = i;
       if ((x_388 < int(15))) {
       } else {
@@ -343,6 +347,10 @@
         lastSampledHeight = x_440;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_441 = i;
         i = (x_441 + int(1));
       }
diff --git a/test/tint/bug/tint/949.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/949.wgsl.expected.ir.fxc.hlsl
index b03e9f5..495ca28 100644
--- a/test/tint/bug/tint/949.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/949.wgsl.expected.ir.fxc.hlsl
@@ -299,7 +299,11 @@
   currSampledHeight = 1.0f;
   i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x_388 = i;
       if ((x_388 < int(15))) {
       } else {
@@ -343,6 +347,10 @@
         lastSampledHeight = x_440;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_441 = i;
         i = (x_441 + int(1));
       }
diff --git a/test/tint/bug/tint/990.wgsl.expected.ir.dxc.hlsl b/test/tint/bug/tint/990.wgsl.expected.ir.dxc.hlsl
index 6814f11..bbfa0af 100644
--- a/test/tint/bug/tint/990.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/bug/tint/990.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/bug/tint/990.wgsl.expected.ir.fxc.hlsl b/test/tint/bug/tint/990.wgsl.expected.ir.fxc.hlsl
index 6814f11..bbfa0af 100644
--- a/test/tint/bug/tint/990.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/bug/tint/990.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.dxc.hlsl
index 9691040..34fe7ea 100644
--- a/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.dxc.hlsl
@@ -18,7 +18,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 6u))) {
         break;
       }
@@ -31,6 +35,10 @@
       uint v_4 = 0u;
       InterlockedExchange(wg[min(v_1, 2u)][min(v_2, 1u)][v_3], 0u, v_4);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.fxc.hlsl
index 9691040..34fe7ea 100644
--- a/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/aliased_arrays.spvasm.expected.ir.fxc.hlsl
@@ -18,7 +18,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 6u))) {
         break;
       }
@@ -31,6 +35,10 @@
       uint v_4 = 0u;
       InterlockedExchange(wg[min(v_1, 2u)][min(v_2, 1u)][v_3], 0u, v_4);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.dxc.hlsl
index 8677f59..f721cf7 100644
--- a/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.dxc.hlsl
@@ -9,7 +9,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 4u))) {
         break;
       }
@@ -17,6 +21,10 @@
       uint v = 0u;
       InterlockedExchange(wg[min(x_26, 3u)], 0u, v);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.fxc.hlsl
index 8677f59..f721cf7 100644
--- a/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/array.spvasm.expected.ir.fxc.hlsl
@@ -9,7 +9,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 4u))) {
         break;
       }
@@ -17,6 +21,10 @@
       uint v = 0u;
       InterlockedExchange(wg[min(x_26, 3u)], 0u, v);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.dxc.hlsl
index 9691040..34fe7ea 100644
--- a/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.dxc.hlsl
@@ -18,7 +18,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 6u))) {
         break;
       }
@@ -31,6 +35,10 @@
       uint v_4 = 0u;
       InterlockedExchange(wg[min(v_1, 2u)][min(v_2, 1u)][v_3], 0u, v_4);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.fxc.hlsl
index 9691040..34fe7ea 100644
--- a/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/atomicStore/array/arrays.spvasm.expected.ir.fxc.hlsl
@@ -18,7 +18,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 6u))) {
         break;
       }
@@ -31,6 +35,10 @@
       uint v_4 = 0u;
       InterlockedExchange(wg[min(v_1, 2u)][min(v_2, 1u)][v_3], 0u, v_4);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.dxc.hlsl
index 6bd54f9..c8903e0 100644
--- a/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.dxc.hlsl
@@ -15,7 +15,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 10u))) {
         break;
       }
@@ -25,6 +29,10 @@
       InterlockedExchange(wg[min(x_28, 9u)].a, 0u, v);
       wg[min(x_28, 9u)].y = 0u;
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.fxc.hlsl
index 6bd54f9..c8903e0 100644
--- a/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/atomicStore/struct/array_of_struct.spvasm.expected.ir.fxc.hlsl
@@ -15,7 +15,11 @@
   uint idx = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 10u))) {
         break;
       }
@@ -25,6 +29,10 @@
       InterlockedExchange(wg[min(x_28, 9u)].a, 0u, v);
       wg[min(x_28, 9u)].y = 0u;
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.dxc.hlsl
index 35b24ab..2edf24f 100644
--- a/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.dxc.hlsl
@@ -17,7 +17,11 @@
   wg.y = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 10u))) {
         break;
       }
@@ -25,6 +29,10 @@
       uint v = 0u;
       InterlockedExchange(wg.a[min(x_35, 9u)], 0u, v);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.fxc.hlsl
index 35b24ab..2edf24f 100644
--- a/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/atomicStore/struct/struct_of_array.spvasm.expected.ir.fxc.hlsl
@@ -17,7 +17,11 @@
   wg.y = 0u;
   idx = local_invocation_index_2;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (!((idx < 10u))) {
         break;
       }
@@ -25,6 +29,10 @@
       uint v = 0u;
       InterlockedExchange(wg.a[min(x_35, 9u)], 0u, v);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         idx = (idx + 1u);
       }
       continue;
diff --git a/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.dxc.hlsl
index 5d578cc..bf100f8 100644
--- a/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 RWTexture2D<int4> tex : register(u2);
 void foo() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(3))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         tex[(int(0)).xx] = (int(0)).xxxx;
       }
       continue;
diff --git a/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.fxc.hlsl
index 5d578cc..bf100f8 100644
--- a/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/textureStore/loop_continuing_read_write_texture.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 RWTexture2D<int4> tex : register(u2);
 void foo() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(3))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         tex[(int(0)).xx] = (int(0)).xxxx;
       }
       continue;
diff --git a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.dxc.hlsl
index 41dcc71..49c1c50 100644
--- a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.dxc.hlsl
@@ -3,8 +3,12 @@
 groupshared int b;
 void foo() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int v = i;
       GroupMemoryBarrierWithGroupSync();
       int v_1 = a;
@@ -14,6 +18,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         GroupMemoryBarrierWithGroupSync();
         int v_2 = b;
         GroupMemoryBarrierWithGroupSync();
diff --git a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.fxc.hlsl
index 41dcc71..49c1c50 100644
--- a/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/workgroupUniformLoad/for_loop.wgsl.expected.ir.fxc.hlsl
@@ -3,8 +3,12 @@
 groupshared int b;
 void foo() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int v = i;
       GroupMemoryBarrierWithGroupSync();
       int v_1 = a;
@@ -14,6 +18,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         GroupMemoryBarrierWithGroupSync();
         int v_2 = b;
         GroupMemoryBarrierWithGroupSync();
diff --git a/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.dxc.hlsl
index 912a641..a1f7ec9 100644
--- a/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.dxc.hlsl
@@ -18,7 +18,11 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v_1 = false;
       if ((x > v.x)) {
         v_1 = (ddx(1.0f) > 0.0f);
@@ -30,6 +34,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.fxc.hlsl b/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.fxc.hlsl
index 912a641..a1f7ec9 100644
--- a/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/diagnostic_filtering/for_loop_attribute.wgsl.expected.ir.fxc.hlsl
@@ -18,7 +18,11 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v_1 = false;
       if ((x > v.x)) {
         v_1 = (ddx(1.0f) > 0.0f);
@@ -30,6 +34,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/diagnostic_filtering/for_loop_body_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/for_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
index 8af9ef8..0eebf88 100644
--- a/test/tint/diagnostic_filtering/for_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/for_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
@@ -20,13 +20,21 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((x > v.x)) {
       } else {
         break;
       }
       v = t.Sample(s, (0.0f).xx);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.dxc.hlsl
index b8cd2ce..43b4fcd 100644
--- a/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.dxc.hlsl
@@ -17,9 +17,17 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       ddx(1.0f);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if ((x > 0.0f)) { break; }
       }
       continue;
diff --git a/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.fxc.hlsl b/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.fxc.hlsl
index b8cd2ce..43b4fcd 100644
--- a/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_attribute.wgsl.expected.ir.fxc.hlsl
@@ -17,9 +17,17 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       ddx(1.0f);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if ((x > 0.0f)) { break; }
       }
       continue;
diff --git a/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.dxc.hlsl
index fac664d..c6838e6 100644
--- a/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.dxc.hlsl
@@ -17,9 +17,17 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       ddx(1.0f);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if ((x > 0.0f)) { break; }
       }
       continue;
diff --git a/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.fxc.hlsl b/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.fxc.hlsl
index fac664d..c6838e6 100644
--- a/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_body_attribute.wgsl.expected.ir.fxc.hlsl
@@ -17,9 +17,17 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       ddx(1.0f);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         if ((x > 0.0f)) { break; }
       }
       continue;
diff --git a/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.dxc.hlsl
index 7234434..ddbf909 100644
--- a/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.dxc.hlsl
@@ -17,8 +17,16 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         ddx(1.0f);
         if ((x > 0.0f)) { break; }
       }
diff --git a/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.fxc.hlsl b/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.fxc.hlsl
index 7234434..ddbf909 100644
--- a/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/diagnostic_filtering/loop_continuing_attribute.wgsl.expected.ir.fxc.hlsl
@@ -17,8 +17,16 @@
 
 void main_inner(float x) {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         ddx(1.0f);
         if ((x > 0.0f)) { break; }
       }
diff --git a/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.dxc.hlsl
index bce8466..cce2207 100644
--- a/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.dxc.hlsl
@@ -18,7 +18,11 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v_1 = false;
       if ((x > 0.0f)) {
         v_1 = (ddx(1.0f) > 0.0f);
@@ -30,6 +34,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.fxc.hlsl b/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.fxc.hlsl
index bce8466..cce2207 100644
--- a/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/diagnostic_filtering/while_loop_attribute.wgsl.expected.ir.fxc.hlsl
@@ -18,7 +18,11 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v_1 = false;
       if ((x > 0.0f)) {
         v_1 = (ddx(1.0f) > 0.0f);
@@ -30,6 +34,10 @@
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/diagnostic_filtering/while_loop_body_attribute.wgsl.expected.ir.dxc.hlsl b/test/tint/diagnostic_filtering/while_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
index 47c5486..48a47e5 100644
--- a/test/tint/diagnostic_filtering/while_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/diagnostic_filtering/while_loop_body_attribute.wgsl.expected.ir.dxc.hlsl
@@ -20,13 +20,21 @@
 void main_inner(float x) {
   float4 v = (0.0f).xxxx;
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((x > v.x)) {
       } else {
         break;
       }
       v = t.Sample(s, (0.0f).xx);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.dxc.hlsl
index e6b2f0d..5e72e58 100644
--- a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.dxc.hlsl
@@ -3,7 +3,11 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(i) {
         case int(0):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i >= int(4))) { break; }
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i >= int(4))) { break; }
       }
diff --git a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.fxc.hlsl
index e6b2f0d..5e72e58 100644
--- a/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/continue_in_switch_with_breakif.wgsl.expected.ir.fxc.hlsl
@@ -3,7 +3,11 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(i) {
         case int(0):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i >= int(4))) { break; }
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i >= int(4))) { break; }
       }
diff --git a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.dxc.hlsl
index e6b2f0d..5e72e58 100644
--- a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.dxc.hlsl
@@ -3,7 +3,11 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(i) {
         case int(0):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i >= int(4))) { break; }
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i >= int(4))) { break; }
       }
diff --git a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.fxc.hlsl
index e6b2f0d..5e72e58 100644
--- a/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/continue_in_switch_with_breakif_robustness.wgsl.expected.ir.fxc.hlsl
@@ -3,7 +3,11 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool tint_continue = false;
       switch(i) {
         case int(0):
@@ -18,12 +22,20 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i >= int(4))) { break; }
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i >= int(4))) { break; }
       }
diff --git a/test/tint/loops/loop.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop.wgsl.expected.ir.dxc.hlsl
index df2c7d0..c467bdf 100644
--- a/test/tint/loops/loop.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop.wgsl.expected.ir.dxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop.wgsl.expected.ir.fxc.hlsl
index df2c7d0..c467bdf 100644
--- a/test/tint/loops/loop.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop.wgsl.expected.ir.fxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop_robustness.wgsl.expected.ir.dxc.hlsl
index df2c7d0..c467bdf 100644
--- a/test/tint/loops/loop_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop_robustness.wgsl.expected.ir.fxc.hlsl
index df2c7d0..c467bdf 100644
--- a/test/tint/loops/loop_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_with_break_if.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop_with_break_if.wgsl.expected.ir.dxc.hlsl
index f2ee415..b8c0a5b 100644
--- a/test/tint/loops/loop_with_break_if.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop_with_break_if.wgsl.expected.ir.dxc.hlsl
@@ -2,11 +2,19 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i == int(4))) { break; }
       }
diff --git a/test/tint/loops/loop_with_break_if.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop_with_break_if.wgsl.expected.ir.fxc.hlsl
index f2ee415..b8c0a5b 100644
--- a/test/tint/loops/loop_with_break_if.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop_with_break_if.wgsl.expected.ir.fxc.hlsl
@@ -2,11 +2,19 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i == int(4))) { break; }
       }
diff --git a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.dxc.hlsl
index f2ee415..b8c0a5b 100644
--- a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,11 +2,19 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i == int(4))) { break; }
       }
diff --git a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.fxc.hlsl
index f2ee415..b8c0a5b 100644
--- a/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop_with_break_if_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,11 +2,19 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
         if ((i == int(4))) { break; }
       }
diff --git a/test/tint/loops/loop_with_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop_with_continuing.wgsl.expected.ir.dxc.hlsl
index cb8a20b..98923fe 100644
--- a/test/tint/loops/loop_with_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop_with_continuing.wgsl.expected.ir.dxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_with_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop_with_continuing.wgsl.expected.ir.fxc.hlsl
index cb8a20b..98923fe 100644
--- a/test/tint/loops/loop_with_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop_with_continuing.wgsl.expected.ir.fxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
index cb8a20b..98923fe 100644
--- a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
index cb8a20b..98923fe 100644
--- a/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/loop_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,17 +2,26 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return i;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.dxc.hlsl
index d529c7a..af70fed 100644
--- a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.dxc.hlsl
@@ -2,15 +2,23 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(0);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j < int(2))) {
           } else {
             break;
@@ -29,17 +37,29 @@
           }
           if (tint_continue) {
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               j = (j + int(2));
             }
             continue;
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(2));
           }
           continue;
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.fxc.hlsl
index d529c7a..af70fed 100644
--- a/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_loop_switch.wgsl.expected.ir.fxc.hlsl
@@ -2,15 +2,23 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(0);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j < int(2))) {
           } else {
             break;
@@ -29,17 +37,29 @@
           }
           if (tint_continue) {
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               j = (j + int(2));
             }
             continue;
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(2));
           }
           continue;
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
index d529c7a..af70fed 100644
--- a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,15 +2,23 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(0);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j < int(2))) {
           } else {
             break;
@@ -29,17 +37,29 @@
           }
           if (tint_continue) {
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               j = (j + int(2));
             }
             continue;
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(2));
           }
           continue;
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
index d529c7a..af70fed 100644
--- a/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,15 +2,23 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         int j = int(0);
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j < int(2))) {
           } else {
             break;
@@ -29,17 +37,29 @@
           }
           if (tint_continue) {
             {
+              uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+              tint_loop_idx_1.x = tint_low_inc_1;
+              uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+              tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
               j = (j + int(2));
             }
             continue;
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(2));
           }
           continue;
         }
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.dxc.hlsl
index 2d688e6..d7351cd 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.dxc.hlsl
@@ -2,8 +2,12 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -13,8 +17,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -33,11 +41,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -53,11 +69,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.fxc.hlsl
index 2d688e6..d7351cd 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.ir.fxc.hlsl
@@ -2,8 +2,12 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -13,8 +17,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -33,11 +41,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -53,11 +69,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
index 2d688e6..d7351cd 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,8 +2,12 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -13,8 +17,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -33,11 +41,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -53,11 +69,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
index 2d688e6..d7351cd 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,8 +2,12 @@
 [numthreads(1, 1, 1)]
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -13,8 +17,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -33,11 +41,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -53,11 +69,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
index 14d5032..94096a7 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int k = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -14,8 +18,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -54,11 +62,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -74,11 +90,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
index 14d5032..94096a7 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int k = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -14,8 +18,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -54,11 +62,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -74,11 +90,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
index 14d5032..94096a7 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int k = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -14,8 +18,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -54,11 +62,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -74,11 +90,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
index 14d5032..94096a7 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int k = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -14,8 +18,12 @@
         case int(0):
         {
           {
+            uint2 tint_loop_idx_1 = (0u).xx;
             int j = int(0);
             while(true) {
+              if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+                break;
+              }
               if ((j < int(2))) {
               } else {
                 break;
@@ -54,11 +62,19 @@
               }
               if (tint_continue_1) {
                 {
+                  uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                  tint_loop_idx_1.x = tint_low_inc_1;
+                  uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                  tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                   j = (j + int(2));
                 }
                 continue;
               }
               {
+                uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+                tint_loop_idx_1.x = tint_low_inc_1;
+                uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+                tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
                 j = (j + int(2));
               }
               continue;
@@ -74,11 +90,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
index 0d67e63..608d41a 100644
--- a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.dxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -38,11 +42,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
index 0d67e63..608d41a 100644
--- a/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_switch.wgsl.expected.ir.fxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -38,11 +42,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
index 0d67e63..608d41a 100644
--- a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.dxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -38,11 +42,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
index 0d67e63..608d41a 100644
--- a/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loop_switch_switch_robustness.wgsl.expected.ir.fxc.hlsl
@@ -3,8 +3,12 @@
 void main() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(2))) {
       } else {
         break;
@@ -38,11 +42,19 @@
       }
       if (tint_continue) {
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(2));
         }
         continue;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(2));
       }
       continue;
diff --git a/test/tint/loops/nested_loops.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loops.wgsl.expected.ir.dxc.hlsl
index be91762..408d692 100644
--- a/test/tint/loops/nested_loops.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loops.wgsl.expected.ir.dxc.hlsl
@@ -3,18 +3,30 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           j = (j + int(1));
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
           }
           continue;
         }
@@ -23,6 +35,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loops.wgsl.expected.ir.fxc.hlsl
index be91762..408d692 100644
--- a/test/tint/loops/nested_loops.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loops.wgsl.expected.ir.fxc.hlsl
@@ -3,18 +3,30 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           j = (j + int(1));
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
           }
           continue;
         }
@@ -23,6 +35,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.dxc.hlsl
index be91762..408d692 100644
--- a/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.dxc.hlsl
@@ -3,18 +3,30 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           j = (j + int(1));
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
           }
           continue;
         }
@@ -23,6 +35,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.fxc.hlsl
index be91762..408d692 100644
--- a/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loops_robustness.wgsl.expected.ir.fxc.hlsl
@@ -3,18 +3,30 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       i = (i + int(1));
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           j = (j + int(1));
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
           }
           continue;
         }
@@ -23,6 +35,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.dxc.hlsl
index cca09d6..75b60e6 100644
--- a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.dxc.hlsl
@@ -3,16 +3,28 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(1));
           }
           continue;
@@ -22,6 +34,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.fxc.hlsl
index cca09d6..75b60e6 100644
--- a/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loops_with_continuing.wgsl.expected.ir.fxc.hlsl
@@ -3,16 +3,28 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(1));
           }
           continue;
@@ -22,6 +34,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
index cca09d6..75b60e6 100644
--- a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.dxc.hlsl
@@ -3,16 +3,28 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(1));
           }
           continue;
@@ -22,6 +34,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
index cca09d6..75b60e6 100644
--- a/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/nested_loops_with_continuing_robustness.wgsl.expected.ir.fxc.hlsl
@@ -3,16 +3,28 @@
   int i = int(0);
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i > int(4))) {
         return int(1);
       }
       {
+        uint2 tint_loop_idx_1 = (0u).xx;
         while(true) {
+          if (all((tint_loop_idx_1 == (4294967295u).xx))) {
+            break;
+          }
           if ((j > int(4))) {
             return int(2);
           }
           {
+            uint tint_low_inc_1 = (tint_loop_idx_1.x + 1u);
+            tint_loop_idx_1.x = tint_low_inc_1;
+            uint tint_carry_1 = uint((tint_low_inc_1 == 0u));
+            tint_loop_idx_1.y = (tint_loop_idx_1.y + tint_carry_1);
             j = (j + int(1));
           }
           continue;
@@ -22,6 +34,7 @@
     }
   }
   /* unreachable */
+  return int(0);
 }
 
 [numthreads(1, 1, 1)]
diff --git a/test/tint/loops/while.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/while.wgsl.expected.ir.dxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/while.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/while.wgsl.expected.ir.fxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/while.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/while_robustness.wgsl.expected.ir.dxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/while_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/while_robustness.wgsl.expected.ir.fxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/while_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_with_continue.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/while_with_continue.wgsl.expected.ir.dxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_with_continue.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/while_with_continue.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_with_continue.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/while_with_continue.wgsl.expected.ir.fxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_with_continue.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/while_with_continue.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.dxc.hlsl b/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.dxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.fxc.hlsl b/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.fxc.hlsl
index fb14300..eae51b1 100644
--- a/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/loops/while_with_continue_robustness.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 int f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/shadowing/loop.wgsl.expected.ir.dxc.hlsl b/test/tint/shadowing/loop.wgsl.expected.ir.dxc.hlsl
index 67f1db9..c6017d0 100644
--- a/test/tint/shadowing/loop.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/shadowing/loop.wgsl.expected.ir.dxc.hlsl
@@ -4,9 +4,17 @@
 void foo() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x = asint(output.Load((0u + (min(uint(i), 9u) * 4u))));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_1 = asint(output.Load((0u + (min(uint(x), 9u) * 4u))));
         i = (i + x_1);
         if ((i > int(10))) { break; }
diff --git a/test/tint/shadowing/loop.wgsl.expected.ir.fxc.hlsl b/test/tint/shadowing/loop.wgsl.expected.ir.fxc.hlsl
index 67f1db9..c6017d0 100644
--- a/test/tint/shadowing/loop.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/shadowing/loop.wgsl.expected.ir.fxc.hlsl
@@ -4,9 +4,17 @@
 void foo() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       int x = asint(output.Load((0u + (min(uint(i), 9u) * 4u))));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int x_1 = asint(output.Load((0u + (min(uint(x), 9u) * 4u))));
         i = (i + x_1);
         if ((i > int(10))) { break; }
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
index 60c4818..ed8cc93 100644
--- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
@@ -15,14 +15,22 @@
   InnerS v = (InnerS)0;
   OuterS s1 = (OuterS)0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         uint v_1 = min(uniforms[0u].x, 7u);
         InnerS v_2 = v;
         s1.a1[v_1] = v_2;
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
index 9412474..c9d30f1 100644
--- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
@@ -15,14 +15,22 @@
   InnerS v = (InnerS)0;
   OuterS s1 = (OuterS)0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       i = (i + int(1));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         uint v_1 = uniforms[0u].x;
         InnerS tint_array_copy[8] = s1.a1;
         InnerS v_2 = v;
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.dxc.hlsl
index 2890b4c..c60bfc4 100644
--- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.dxc.hlsl
@@ -16,15 +16,23 @@
   OuterS s1 = (OuterS)0;
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v_1 = min(uniforms[0u].x, 7u);
     InnerS v_2 = v;
     s1.a1[v_1] = v_2;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.fxc.hlsl
index 370a15b..b2242af 100644
--- a/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/assign/indexed_assign_to_array_in_struct/in_for_loop_init.wgsl.expected.ir.fxc.hlsl
@@ -16,6 +16,7 @@
   OuterS s1 = (OuterS)0;
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v_1 = uniforms[0u].x;
     InnerS tint_array_copy[8] = s1.a1;
     InnerS v_2 = v;
@@ -23,11 +24,18 @@
     InnerS v_3[8] = tint_array_copy;
     s1.a1 = v_3;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.dxc.hlsl
index 56cbb14..8e8b420 100644
--- a/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.dxc.hlsl
@@ -19,15 +19,23 @@
 void foo() {
   float a[4] = (float[4])0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v_1 = min(uint(idx1()), 3u);
     a[v_1] = (a[v_1] * 2.0f);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v_2 = min(uint(idx2()), 3u);
       if ((a[v_2] < 10.0f)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         uint v_3 = min(uint(idx3()), 3u);
         a[v_3] = (a[v_3] + 1.0f);
       }
diff --git a/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.fxc.hlsl
index 56cbb14..8e8b420 100644
--- a/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/compound_assign/for_loop.wgsl.expected.ir.fxc.hlsl
@@ -19,15 +19,23 @@
 void foo() {
   float a[4] = (float[4])0;
   {
+    uint2 tint_loop_idx = (0u).xx;
     uint v_1 = min(uint(idx1()), 3u);
     a[v_1] = (a[v_1] * 2.0f);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       uint v_2 = min(uint(idx2()), 3u);
       if ((a[v_2] < 10.0f)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         uint v_3 = min(uint(idx3()), 3u);
         a[v_3] = (a[v_3] + 1.0f);
       }
diff --git a/test/tint/statements/decrement/complex.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/decrement/complex.wgsl.expected.ir.dxc.hlsl
index 8882183..3a5d870 100644
--- a/test/tint/statements/decrement/complex.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/decrement/complex.wgsl.expected.ir.dxc.hlsl
@@ -33,6 +33,7 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int v_1 = idx1();
     int v_2 = idx2();
     uint v_3 = 0u;
@@ -44,11 +45,18 @@
     int v_8 = (asint(buffer.Load((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)))) - int(1));
     buffer.Store((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)), asuint(v_8));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((v < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v_9 = idx4();
         int v_10 = idx5();
         uint v_11 = 0u;
diff --git a/test/tint/statements/decrement/complex.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/decrement/complex.wgsl.expected.ir.fxc.hlsl
index 8882183..3a5d870 100644
--- a/test/tint/statements/decrement/complex.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/decrement/complex.wgsl.expected.ir.fxc.hlsl
@@ -33,6 +33,7 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int v_1 = idx1();
     int v_2 = idx2();
     uint v_3 = 0u;
@@ -44,11 +45,18 @@
     int v_8 = (asint(buffer.Load((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)))) - int(1));
     buffer.Store((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)), asuint(v_8));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((v < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v_9 = idx4();
         int v_10 = idx5();
         uint v_11 = 0u;
diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
index 8a35549..6641e73 100644
--- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i.Store(0u, (i.Load(0u) - 1u));
       }
       continue;
diff --git a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
index 8a35549..6641e73 100644
--- a/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/decrement/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i.Store(0u, (i.Load(0u) - 1u));
       }
       continue;
diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
index 370e876..640e36f 100644
--- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     i.Store(0u, (i.Load(0u) - 1u));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
index 370e876..640e36f 100644
--- a/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/decrement/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     i.Store(0u, (i.Load(0u) - 1u));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
index 6f7b4aa..6ecf4b8 100644
--- a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.dxc.hlsl
@@ -21,14 +21,22 @@
   }
   int result = tint_f32_to_i32(t.Sample(s, coord).x);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(10))) {
       } else {
         break;
       }
       result = (result + i);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v = int(0);
         a.InterlockedAdd(int(0u), int(1), v);
         i = v;
diff --git a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
index 44c3a04..b0e8652 100644
--- a/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/discard/atomic_in_for_loop_continuing.wgsl.expected.ir.fxc.hlsl
@@ -22,14 +22,22 @@
   }
   int result = tint_f32_to_i32(t.Sample(s, coord).x);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(10))) {
       } else {
         break;
       }
       result = (result + i);
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v = int(0);
         if (continue_execution) {
           int v_1 = int(0);
diff --git a/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.dxc.hlsl
index 3df9c0c..d9f11f8 100644
--- a/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.dxc.hlsl
@@ -1,7 +1,11 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       discard;
       return;
     }
diff --git a/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.fxc.hlsl
index 7bf75a1..b72fd4c 100644
--- a/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/discard/loop_discard_return.wgsl.expected.ir.fxc.hlsl
@@ -2,7 +2,11 @@
 static bool continue_execution = true;
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       continue_execution = false;
       return;
     }
diff --git a/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.dxc.hlsl
index cedc65b..e71074d 100644
--- a/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.dxc.hlsl
@@ -9,13 +9,21 @@
   if ((asfloat(output.Load(0u)) < 0.0f)) {
     int i = int(0);
     {
+      uint2 tint_loop_idx = (0u).xx;
       while(true) {
+        if (all((tint_loop_idx == (4294967295u).xx))) {
+          break;
+        }
         float v = asfloat(output.Load(0u));
         if ((v > float(i))) {
           output.Store(0u, asuint(float(i)));
           return;
         }
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i == int(5))) { break; }
         }
diff --git a/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.fxc.hlsl
index 5f19b59..e464429 100644
--- a/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/discard/multiple_returns.wgsl.expected.ir.fxc.hlsl
@@ -13,7 +13,11 @@
   if ((asfloat(output.Load(0u)) < 0.0f)) {
     int i = int(0);
     {
+      uint2 tint_loop_idx = (0u).xx;
       while(true) {
+        if (all((tint_loop_idx == (4294967295u).xx))) {
+          break;
+        }
         float v_1 = asfloat(output.Load(0u));
         if ((v_1 > float(i))) {
           float v_2 = float(i);
@@ -26,6 +30,10 @@
           return;
         }
         {
+          uint tint_low_inc = (tint_loop_idx.x + 1u);
+          tint_loop_idx.x = tint_low_inc;
+          uint tint_carry = uint((tint_low_inc == 0u));
+          tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
           i = (i + int(1));
           if ((i == int(5))) { break; }
         }
diff --git a/test/tint/statements/for/complex.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/complex.wgsl.expected.ir.dxc.hlsl
index 13b0132..978f106 100644
--- a/test/tint/statements/for/complex.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/complex.wgsl.expected.ir.dxc.hlsl
@@ -5,8 +5,12 @@
 void f() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v = false;
       if ((i < int(5))) {
         v = (j < int(10));
@@ -20,6 +24,10 @@
       some_loop_body();
       j = (i * int(30));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/complex.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/complex.wgsl.expected.ir.fxc.hlsl
index 13b0132..978f106 100644
--- a/test/tint/statements/for/complex.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/complex.wgsl.expected.ir.fxc.hlsl
@@ -5,8 +5,12 @@
 void f() {
   int j = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       bool v = false;
       if ((i < int(5))) {
         v = (j < int(10));
@@ -20,6 +24,10 @@
       some_loop_body();
       j = (i * int(30));
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.dxc.hlsl
index cfadc281..ef0b612 100644
--- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.fxc.hlsl
index cfadc281..ef0b612 100644
--- a/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/condition/array_ctor.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/condition/basic.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/condition/basic.wgsl.expected.ir.dxc.hlsl
index 6bee681..93e0c79 100644
--- a/test/tint/statements/for/condition/basic.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/condition/basic.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/condition/basic.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/condition/basic.wgsl.expected.ir.fxc.hlsl
index 6bee681..93e0c79 100644
--- a/test/tint/statements/for/condition/basic.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/condition/basic.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(4))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.dxc.hlsl
index cfadc281..ef0b612 100644
--- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.fxc.hlsl
index cfadc281..ef0b612 100644
--- a/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/condition/struct_ctor.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i < int(1))) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.dxc.hlsl
index 1c27303..c5021e6 100644
--- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.fxc.hlsl
index 1c27303..c5021e6 100644
--- a/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/continuing/array_ctor.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/continuing/basic.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/continuing/basic.wgsl.expected.ir.dxc.hlsl
index 1c27303..c5021e6 100644
--- a/test/tint/statements/for/continuing/basic.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/continuing/basic.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/continuing/basic.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/continuing/basic.wgsl.expected.ir.fxc.hlsl
index 1c27303..c5021e6 100644
--- a/test/tint/statements/for/continuing/basic.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/continuing/basic.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 void f() {
   int i = int(0);
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.dxc.hlsl
index 1816bf5..3045968 100644
--- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.dxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.fxc.hlsl
index 1816bf5..3045968 100644
--- a/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/continuing/struct_ctor.wgsl.expected.ir.fxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i = (i + int(1));
       }
       continue;
diff --git a/test/tint/statements/for/empty.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/empty.wgsl.expected.ir.dxc.hlsl
index d8bd76e..8b405e0 100644
--- a/test/tint/statements/for/empty.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/empty.wgsl.expected.ir.dxc.hlsl
@@ -1,12 +1,20 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/empty.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/empty.wgsl.expected.ir.fxc.hlsl
index d8bd76e..8b405e0 100644
--- a/test/tint/statements/for/empty.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/empty.wgsl.expected.ir.fxc.hlsl
@@ -1,12 +1,20 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.dxc.hlsl
index b389e68..ad6dcaf 100644
--- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.dxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(1);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.fxc.hlsl
index b389e68..ad6dcaf 100644
--- a/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/initializer/array_ctor.wgsl.expected.ir.fxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(1);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/basic.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/initializer/basic.wgsl.expected.ir.dxc.hlsl
index aa2c684..1bfed0c 100644
--- a/test/tint/statements/for/initializer/basic.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/initializer/basic.wgsl.expected.ir.dxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/basic.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/initializer/basic.wgsl.expected.ir.fxc.hlsl
index aa2c684..1bfed0c 100644
--- a/test/tint/statements/for/initializer/basic.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/initializer/basic.wgsl.expected.ir.fxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.dxc.hlsl
index b389e68..ad6dcaf 100644
--- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.dxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(1);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.fxc.hlsl
index b389e68..ad6dcaf 100644
--- a/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/initializer/struct_ctor.wgsl.expected.ir.fxc.hlsl
@@ -1,13 +1,21 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int i = int(1);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if (false) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/for/scoping.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/for/scoping.wgsl.expected.ir.dxc.hlsl
index 94a7357..b70678f 100644
--- a/test/tint/statements/for/scoping.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/for/scoping.wgsl.expected.ir.dxc.hlsl
@@ -1,8 +1,12 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int must_not_collide = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       break;
     }
   }
diff --git a/test/tint/statements/for/scoping.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/for/scoping.wgsl.expected.ir.fxc.hlsl
index 94a7357..b70678f 100644
--- a/test/tint/statements/for/scoping.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/for/scoping.wgsl.expected.ir.fxc.hlsl
@@ -1,8 +1,12 @@
 
 void f() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int must_not_collide = int(0);
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       break;
     }
   }
diff --git a/test/tint/statements/increment/complex.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/increment/complex.wgsl.expected.ir.dxc.hlsl
index 50d2db9..2532399 100644
--- a/test/tint/statements/increment/complex.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/increment/complex.wgsl.expected.ir.dxc.hlsl
@@ -33,6 +33,7 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int v_1 = idx1();
     int v_2 = idx2();
     uint v_3 = 0u;
@@ -44,11 +45,18 @@
     int v_8 = (asint(buffer.Load((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)))) + int(1));
     buffer.Store((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)), asuint(v_8));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((v < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v_9 = idx4();
         int v_10 = idx5();
         uint v_11 = 0u;
diff --git a/test/tint/statements/increment/complex.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/increment/complex.wgsl.expected.ir.fxc.hlsl
index 50d2db9..2532399 100644
--- a/test/tint/statements/increment/complex.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/increment/complex.wgsl.expected.ir.fxc.hlsl
@@ -33,6 +33,7 @@
 
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     int v_1 = idx1();
     int v_2 = idx2();
     uint v_3 = 0u;
@@ -44,11 +45,18 @@
     int v_8 = (asint(buffer.Load((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)))) + int(1));
     buffer.Store((((0u + (v_5 * 64u)) + v_6) + (min(uint(v_7), 3u) * 4u)), asuint(v_8));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((v < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         int v_9 = idx4();
         int v_10 = idx5();
         uint v_11 = 0u;
diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
index 8bb83a9..922c7d2 100644
--- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.dxc.hlsl
@@ -2,12 +2,20 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i.Store(0u, (i.Load(0u) + 1u));
       }
       continue;
diff --git a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
index 8bb83a9..922c7d2 100644
--- a/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/increment/for_loop_continuing.wgsl.expected.ir.fxc.hlsl
@@ -2,12 +2,20 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
         i.Store(0u, (i.Load(0u) + 1u));
       }
       continue;
diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.dxc.hlsl b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
index a8b341a..1d2fdba 100644
--- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.dxc.hlsl
@@ -2,13 +2,21 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     i.Store(0u, (i.Load(0u) + 1u));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }
diff --git a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.fxc.hlsl b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
index a8b341a..1d2fdba 100644
--- a/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/statements/increment/for_loop_initializer.wgsl.expected.ir.fxc.hlsl
@@ -2,13 +2,21 @@
 RWByteAddressBuffer i : register(u0);
 void main() {
   {
+    uint2 tint_loop_idx = (0u).xx;
     i.Store(0u, (i.Load(0u) + 1u));
     while(true) {
+      if (all((tint_loop_idx == (4294967295u).xx))) {
+        break;
+      }
       if ((i.Load(0u) < 10u)) {
       } else {
         break;
       }
       {
+        uint tint_low_inc = (tint_loop_idx.x + 1u);
+        tint_loop_idx.x = tint_low_inc;
+        uint tint_carry = uint((tint_low_inc == 0u));
+        tint_loop_idx.y = (tint_loop_idx.y + tint_carry);
       }
       continue;
     }