HLSL-IR: implement extractBits full polyfill

Implemented as a general polyfill, but only used by the HLSL backend
currently.

Tested CTS using dawn_node with `-use-ir` and the following now pass:
`webgpu:shader,execution,expression,call,builtin,extractBits:*`
`webgpu:shader,validation,expression,call,builtin,extractBits:*`

Bug: b/363199437
Bug: b/42251045
Change-Id: I4137f507d0b7050b23adebdd284cb262b1c976c6
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/206114
Commit-Queue: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/core/ir/transform/builtin_polyfill.cc b/src/tint/lang/core/ir/transform/builtin_polyfill.cc
index bb2c09e..d2d3ae8 100644
--- a/src/tint/lang/core/ir/transform/builtin_polyfill.cc
+++ b/src/tint/lang/core/ir/transform/builtin_polyfill.cc
@@ -393,7 +393,6 @@
     void ExtractBits(ir::CoreBuiltinCall* call) {
         auto* offset = call->Args()[1];
         auto* count = call->Args()[2];
-
         switch (config.extract_bits) {
             case BuiltinPolyfillLevel::kClampOrRangeCheck: {
                 b.InsertBefore(call, [&] {
@@ -409,8 +408,39 @@
                     call->SetOperand(ir::CoreBuiltinCall::kArgsOperandOffset + 1, o->Result(0));
                     call->SetOperand(ir::CoreBuiltinCall::kArgsOperandOffset + 2, c->Result(0));
                 });
-                break;
-            }
+            } break;
+            case BuiltinPolyfillLevel::kFull: {
+                // Replace:
+                //    result = extractBits(v, offset, count)
+                // With:
+                //   let s = min(offset, 32u);
+                //   let e = min(32u, (s + count));
+                //   let shl = (32u - e);
+                //   let shr = (shl + s);
+                //   let shl_result = select(i32(), (v << shl), (shl < 32u));
+                //   result = select(((shl_result >> 31u) >> 1u), (shl_result >> shr), (shr < 32u));
+                // }
+                auto* v = call->Args()[0];
+                auto* result_ty = v->Type();
+                auto* uint_ty = ty.match_width(ty.u32(), result_ty);
+                auto V = [&](uint32_t u) { return b.MatchWidth(u32(u), result_ty); };
+                b.InsertBefore(call, [&] {
+                    auto* s = b.Call<u32>(core::BuiltinFn::kMin, offset, 32_u);
+                    auto* e = b.Call<u32>(core::BuiltinFn::kMin, 32_u, b.Add(ty.u32(), s, count));
+                    auto* shl = b.Subtract<u32>(32_u, e);
+                    auto* shr = b.Add<u32>(shl, s);
+                    auto* f1 = b.Zero(result_ty);
+                    auto* t1 = b.ShiftLeft(result_ty, v, b.Construct(uint_ty, shl));
+                    auto* shl_result = b.Call(result_ty, core::BuiltinFn::kSelect, f1, t1,
+                                              b.LessThan<bool>(shl, 32_u));
+                    auto* f2 =
+                        b.ShiftRight(result_ty, b.ShiftRight(result_ty, shl_result, V(31)), V(1));
+                    auto* t2 = b.ShiftRight(result_ty, shl_result, b.Construct(uint_ty, shr));
+                    b.CallWithResult(call->DetachResult(), core::BuiltinFn::kSelect, f2, t2,
+                                     b.LessThan<bool>(shr, 32_u));
+                });
+                call->Destroy();
+            } break;
             default:
                 TINT_UNIMPLEMENTED() << "extractBits polyfill level";
         }
diff --git a/src/tint/lang/core/ir/transform/builtin_polyfill_test.cc b/src/tint/lang/core/ir/transform/builtin_polyfill_test.cc
index 6aec3b2..5a3c740 100644
--- a/src/tint/lang/core/ir/transform/builtin_polyfill_test.cc
+++ b/src/tint/lang/core/ir/transform/builtin_polyfill_test.cc
@@ -878,6 +878,172 @@
     EXPECT_EQ(expect, str());
 }
 
+TEST_F(IR_BuiltinPolyfillTest, ExtractBits_Full_U32) {
+    Build(core::BuiltinFn::kExtractBits, ty.u32(), Vector{ty.u32(), ty.u32(), ty.u32()});
+    auto* src = R"(
+%foo = func(%arg:u32, %arg_1:u32, %arg_2:u32):u32 {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %result:u32 = extractBits %arg, %arg_1, %arg_2
+    ret %result
+  }
+}
+)";
+    auto* expect = R"(
+%foo = func(%arg:u32, %arg_1:u32, %arg_2:u32):u32 {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %5:u32 = min %arg_1, 32u
+    %6:u32 = add %5, %arg_2
+    %7:u32 = min 32u, %6
+    %8:u32 = sub 32u, %7
+    %9:u32 = add %8, %5
+    %10:u32 = construct %8
+    %11:u32 = shl %arg, %10
+    %12:bool = lt %8, 32u
+    %13:u32 = select 0u, %11, %12
+    %14:u32 = shr %13, 31u
+    %15:u32 = shr %14, 1u
+    %16:u32 = construct %9
+    %17:u32 = shr %13, %16
+    %18:bool = lt %9, 32u
+    %result:u32 = select %15, %17, %18
+    ret %result
+  }
+}
+)";
+
+    EXPECT_EQ(src, str());
+
+    BuiltinPolyfillConfig config;
+    config.extract_bits = BuiltinPolyfillLevel::kFull;
+    Run(BuiltinPolyfill, config);
+    EXPECT_EQ(expect, str());
+}
+
+TEST_F(IR_BuiltinPolyfillTest, ExtractBits_Full_I32) {
+    Build(core::BuiltinFn::kExtractBits, ty.i32(), Vector{ty.i32(), ty.u32(), ty.u32()});
+    auto* src = R"(
+%foo = func(%arg:i32, %arg_1:u32, %arg_2:u32):i32 {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %result:i32 = extractBits %arg, %arg_1, %arg_2
+    ret %result
+  }
+}
+)";
+    auto* expect = R"(
+%foo = func(%arg:i32, %arg_1:u32, %arg_2:u32):i32 {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %5:u32 = min %arg_1, 32u
+    %6:u32 = add %5, %arg_2
+    %7:u32 = min 32u, %6
+    %8:u32 = sub 32u, %7
+    %9:u32 = add %8, %5
+    %10:u32 = construct %8
+    %11:i32 = shl %arg, %10
+    %12:bool = lt %8, 32u
+    %13:i32 = select 0i, %11, %12
+    %14:i32 = shr %13, 31u
+    %15:i32 = shr %14, 1u
+    %16:u32 = construct %9
+    %17:i32 = shr %13, %16
+    %18:bool = lt %9, 32u
+    %result:i32 = select %15, %17, %18
+    ret %result
+  }
+}
+)";
+
+    EXPECT_EQ(src, str());
+
+    BuiltinPolyfillConfig config;
+    config.extract_bits = BuiltinPolyfillLevel::kFull;
+    Run(BuiltinPolyfill, config);
+    EXPECT_EQ(expect, str());
+}
+
+TEST_F(IR_BuiltinPolyfillTest, ExtractBits_Full_Vec2U32) {
+    Build(core::BuiltinFn::kExtractBits, ty.vec2<u32>(),
+          Vector{ty.vec2<u32>(), ty.u32(), ty.u32()});
+    auto* src = R"(
+%foo = func(%arg:vec2<u32>, %arg_1:u32, %arg_2:u32):vec2<u32> {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %result:vec2<u32> = extractBits %arg, %arg_1, %arg_2
+    ret %result
+  }
+}
+)";
+    auto* expect = R"(
+%foo = func(%arg:vec2<u32>, %arg_1:u32, %arg_2:u32):vec2<u32> {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %5:u32 = min %arg_1, 32u
+    %6:u32 = add %5, %arg_2
+    %7:u32 = min 32u, %6
+    %8:u32 = sub 32u, %7
+    %9:u32 = add %8, %5
+    %10:vec2<u32> = construct %8
+    %11:vec2<u32> = shl %arg, %10
+    %12:bool = lt %8, 32u
+    %13:vec2<u32> = select vec2<u32>(0u), %11, %12
+    %14:vec2<u32> = shr %13, vec2<u32>(31u)
+    %15:vec2<u32> = shr %14, vec2<u32>(1u)
+    %16:vec2<u32> = construct %9
+    %17:vec2<u32> = shr %13, %16
+    %18:bool = lt %9, 32u
+    %result:vec2<u32> = select %15, %17, %18
+    ret %result
+  }
+}
+)";
+
+    EXPECT_EQ(src, str());
+
+    BuiltinPolyfillConfig config;
+    config.extract_bits = BuiltinPolyfillLevel::kFull;
+    Run(BuiltinPolyfill, config);
+    EXPECT_EQ(expect, str());
+}
+
+TEST_F(IR_BuiltinPolyfillTest, ExtractBits_Full_Vec4I32) {
+    Build(core::BuiltinFn::kExtractBits, ty.vec4<i32>(),
+          Vector{ty.vec4<i32>(), ty.u32(), ty.u32()});
+    auto* src = R"(
+%foo = func(%arg:vec4<i32>, %arg_1:u32, %arg_2:u32):vec4<i32> {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %result:vec4<i32> = extractBits %arg, %arg_1, %arg_2
+    ret %result
+  }
+}
+)";
+    auto* expect = R"(
+%foo = func(%arg:vec4<i32>, %arg_1:u32, %arg_2:u32):vec4<i32> {  # %arg_1: 'arg', %arg_2: 'arg'
+  $B1: {
+    %5:u32 = min %arg_1, 32u
+    %6:u32 = add %5, %arg_2
+    %7:u32 = min 32u, %6
+    %8:u32 = sub 32u, %7
+    %9:u32 = add %8, %5
+    %10:vec4<u32> = construct %8
+    %11:vec4<i32> = shl %arg, %10
+    %12:bool = lt %8, 32u
+    %13:vec4<i32> = select vec4<i32>(0i), %11, %12
+    %14:vec4<i32> = shr %13, vec4<u32>(31u)
+    %15:vec4<i32> = shr %14, vec4<u32>(1u)
+    %16:vec4<u32> = construct %9
+    %17:vec4<i32> = shr %13, %16
+    %18:bool = lt %9, 32u
+    %result:vec4<i32> = select %15, %17, %18
+    ret %result
+  }
+}
+)";
+
+    EXPECT_EQ(src, str());
+
+    BuiltinPolyfillConfig config;
+    config.extract_bits = BuiltinPolyfillLevel::kFull;
+    Run(BuiltinPolyfill, config);
+    EXPECT_EQ(expect, str());
+}
+
 TEST_F(IR_BuiltinPolyfillTest, FirstLeadingBit_NoPolyfill) {
     Build(core::BuiltinFn::kFirstLeadingBit, ty.u32(), Vector{ty.u32()});
     auto* src = R"(
diff --git a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.dxc.hlsl
index abcc822..8473a27 100644
--- a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.dxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  int v = 0;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  int v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  int v_5 = (((v_4 < 32u)) ? ((v_1 << uint(v_4))) : (0));
+  int x_14 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint((v_4 + v_3)))) : (((v_5 >> 31u) >> 1u)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.fxc.hlsl
index abcc822..8473a27 100644
--- a/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/extractBits/scalar/i32.spvasm.expected.ir.fxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  int v = 0;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  int v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  int v_5 = (((v_4 < 32u)) ? ((v_1 << uint(v_4))) : (0));
+  int x_14 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint((v_4 + v_3)))) : (((v_5 >> 31u) >> 1u)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.dxc.hlsl
index abcc822..accacc2 100644
--- a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.dxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  uint v = 0u;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  uint v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  uint v_5 = (((v_4 < 32u)) ? ((v_1 << uint(v_4))) : (0u));
+  uint x_11 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint((v_4 + v_3)))) : (((v_5 >> 31u) >> 1u)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.fxc.hlsl
index abcc822..accacc2 100644
--- a/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/extractBits/scalar/u32.spvasm.expected.ir.fxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  uint v = 0u;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  uint v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  uint v_5 = (((v_4 < 32u)) ? ((v_1 << uint(v_4))) : (0u));
+  uint x_11 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint((v_4 + v_3)))) : (((v_5 >> 31u) >> 1u)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.dxc.hlsl
index abcc822..b70f3e0 100644
--- a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.dxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  int3 v = (0).xxx;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  int3 v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  int3 v_5 = (((v_4 < 32u)) ? ((v_1 << uint3((v_4).xxx))) : ((0).xxx));
+  int3 x_15 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint3(((v_4 + v_3)).xxx))) : (((v_5 >> (31u).xxx) >> (1u).xxx)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.fxc.hlsl
index abcc822..b70f3e0 100644
--- a/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/extractBits/vec3/i32.spvasm.expected.ir.fxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  int3 v = (0).xxx;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  int3 v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  int3 v_5 = (((v_4 < 32u)) ? ((v_1 << uint3((v_4).xxx))) : ((0).xxx));
+  int3 x_15 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint3(((v_4 + v_3)).xxx))) : (((v_5 >> (31u).xxx) >> (1u).xxx)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.dxc.hlsl b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.dxc.hlsl
index abcc822..d5f82b0 100644
--- a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.dxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  uint3 v = (0u).xxx;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  uint3 v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  uint3 v_5 = (((v_4 < 32u)) ? ((v_1 << uint3((v_4).xxx))) : ((0u).xxx));
+  uint3 x_14 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint3(((v_4 + v_3)).xxx))) : (((v_5 >> (31u).xxx) >> (1u).xxx)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.fxc.hlsl b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.fxc.hlsl
index abcc822..d5f82b0 100644
--- a/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/extractBits/vec3/u32.spvasm.expected.ir.fxc.hlsl
@@ -1,11 +1,18 @@
-SKIP: FAILED
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+void f_1() {
+  uint3 v = (0u).xxx;
+  uint offset_1 = 0u;
+  uint count = 0u;
+  uint3 v_1 = v;
+  uint v_2 = count;
+  uint v_3 = min(offset_1, 32u);
+  uint v_4 = (32u - min(32u, (v_3 + v_2)));
+  uint3 v_5 = (((v_4 < 32u)) ? ((v_1 << uint3((v_4).xxx))) : ((0u).xxx));
+  uint3 x_14 = ((((v_4 + v_3) < 32u)) ? ((v_5 >> uint3(((v_4 + v_3)).xxx))) : (((v_5 >> (31u).xxx) >> (1u).xxx)));
+}
 
-tint executable returned error: exit status 0xc000001d
+[numthreads(1, 1, 1)]
+void f() {
+  f_1();
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.dxc.hlsl
index abcc822..9f58474 100644
--- a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint3 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint3 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint3 extractBits_12b197() {
+  uint3 arg_0 = (1u).xxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint3 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint3 v_4 = (((v_3 < 32u)) ? ((v << uint3((v_3).xxx))) : ((0u).xxx));
+  uint3 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint3(((v_3 + v_2)).xxx))) : (((v_4 >> (31u).xxx) >> (1u).xxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store3(0u, extractBits_12b197());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store3(0u, extractBits_12b197());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_12b197();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.fxc.hlsl
index abcc822..9f58474 100644
--- a/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/12b197.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint3 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint3 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint3 extractBits_12b197() {
+  uint3 arg_0 = (1u).xxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint3 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint3 v_4 = (((v_3 < 32u)) ? ((v << uint3((v_3).xxx))) : ((0u).xxx));
+  uint3 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint3(((v_3 + v_2)).xxx))) : (((v_4 >> (31u).xxx) >> (1u).xxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store3(0u, extractBits_12b197());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store3(0u, extractBits_12b197());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_12b197();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.dxc.hlsl
index abcc822..df2a694 100644
--- a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int extractBits_249874() {
+  int arg_0 = 1;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int v_4 = (((v_3 < 32u)) ? ((v << uint(v_3))) : (0));
+  int res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint((v_3 + v_2)))) : (((v_4 >> 31u) >> 1u)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store(0u, asuint(extractBits_249874()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store(0u, asuint(extractBits_249874()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_249874();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.fxc.hlsl
index abcc822..df2a694 100644
--- a/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/249874.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int extractBits_249874() {
+  int arg_0 = 1;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int v_4 = (((v_3 < 32u)) ? ((v << uint(v_3))) : (0));
+  int res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint((v_3 + v_2)))) : (((v_4 >> 31u) >> 1u)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store(0u, asuint(extractBits_249874()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store(0u, asuint(extractBits_249874()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_249874();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.dxc.hlsl
index abcc822..2359ebd 100644
--- a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint4 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint4 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint4 extractBits_631377() {
+  uint4 arg_0 = (1u).xxxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint4 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint4 v_4 = (((v_3 < 32u)) ? ((v << uint4((v_3).xxxx))) : ((0u).xxxx));
+  uint4 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint4(((v_3 + v_2)).xxxx))) : (((v_4 >> (31u).xxxx) >> (1u).xxxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store4(0u, extractBits_631377());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store4(0u, extractBits_631377());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_631377();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.fxc.hlsl
index abcc822..2359ebd 100644
--- a/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/631377.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint4 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint4 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint4 extractBits_631377() {
+  uint4 arg_0 = (1u).xxxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint4 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint4 v_4 = (((v_3 < 32u)) ? ((v << uint4((v_3).xxxx))) : ((0u).xxxx));
+  uint4 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint4(((v_3 + v_2)).xxxx))) : (((v_4 >> (31u).xxxx) >> (1u).xxxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store4(0u, extractBits_631377());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store4(0u, extractBits_631377());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_631377();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.dxc.hlsl
index abcc822..4fe2dd2 100644
--- a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int2 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int2 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int2 extractBits_a99a8d() {
+  int2 arg_0 = (1).xx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int2 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int2 v_4 = (((v_3 < 32u)) ? ((v << uint2((v_3).xx))) : ((0).xx));
+  int2 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint2(((v_3 + v_2)).xx))) : (((v_4 >> (31u).xx) >> (1u).xx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store2(0u, asuint(extractBits_a99a8d()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store2(0u, asuint(extractBits_a99a8d()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_a99a8d();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.fxc.hlsl
index abcc822..4fe2dd2 100644
--- a/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/a99a8d.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int2 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int2 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int2 extractBits_a99a8d() {
+  int2 arg_0 = (1).xx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int2 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int2 v_4 = (((v_3 < 32u)) ? ((v << uint2((v_3).xx))) : ((0).xx));
+  int2 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint2(((v_3 + v_2)).xx))) : (((v_4 >> (31u).xx) >> (1u).xx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store2(0u, asuint(extractBits_a99a8d()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store2(0u, asuint(extractBits_a99a8d()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_a99a8d();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.dxc.hlsl
index abcc822..b48c72b 100644
--- a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint extractBits_ce81f8() {
+  uint arg_0 = 1u;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint v_4 = (((v_3 < 32u)) ? ((v << uint(v_3))) : (0u));
+  uint res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint((v_3 + v_2)))) : (((v_4 >> 31u) >> 1u)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store(0u, extractBits_ce81f8());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store(0u, extractBits_ce81f8());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_ce81f8();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.fxc.hlsl
index abcc822..b48c72b 100644
--- a/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/ce81f8.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint extractBits_ce81f8() {
+  uint arg_0 = 1u;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint v_4 = (((v_3 < 32u)) ? ((v << uint(v_3))) : (0u));
+  uint res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint((v_3 + v_2)))) : (((v_4 >> 31u) >> 1u)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store(0u, extractBits_ce81f8());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store(0u, extractBits_ce81f8());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_ce81f8();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.dxc.hlsl
index abcc822..814db83 100644
--- a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int3 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int3 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int3 extractBits_e04f5d() {
+  int3 arg_0 = (1).xxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int3 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int3 v_4 = (((v_3 < 32u)) ? ((v << uint3((v_3).xxx))) : ((0).xxx));
+  int3 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint3(((v_3 + v_2)).xxx))) : (((v_4 >> (31u).xxx) >> (1u).xxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store3(0u, asuint(extractBits_e04f5d()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store3(0u, asuint(extractBits_e04f5d()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_e04f5d();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.fxc.hlsl
index abcc822..814db83 100644
--- a/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/e04f5d.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int3 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int3 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int3 extractBits_e04f5d() {
+  int3 arg_0 = (1).xxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int3 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int3 v_4 = (((v_3 < 32u)) ? ((v << uint3((v_3).xxx))) : ((0).xxx));
+  int3 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint3(((v_3 + v_2)).xxx))) : (((v_4 >> (31u).xxx) >> (1u).xxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store3(0u, asuint(extractBits_e04f5d()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store3(0u, asuint(extractBits_e04f5d()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_e04f5d();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.dxc.hlsl
index abcc822..36c0f54 100644
--- a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint2 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint2 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint2 extractBits_f28f69() {
+  uint2 arg_0 = (1u).xx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint2 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint2 v_4 = (((v_3 < 32u)) ? ((v << uint2((v_3).xx))) : ((0u).xx));
+  uint2 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint2(((v_3 + v_2)).xx))) : (((v_4 >> (31u).xx) >> (1u).xx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store2(0u, extractBits_f28f69());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store2(0u, extractBits_f28f69());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_f28f69();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.fxc.hlsl
index abcc822..36c0f54 100644
--- a/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/f28f69.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  uint2 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation uint2 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+uint2 extractBits_f28f69() {
+  uint2 arg_0 = (1u).xx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  uint2 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  uint2 v_4 = (((v_3 < 32u)) ? ((v << uint2((v_3).xx))) : ((0u).xx));
+  uint2 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint2(((v_3 + v_2)).xx))) : (((v_4 >> (31u).xx) >> (1u).xx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store2(0u, extractBits_f28f69());
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store2(0u, extractBits_f28f69());
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_f28f69();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.dxc.hlsl b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.dxc.hlsl
index abcc822..ab78a9f 100644
--- a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.dxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.dxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int4 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int4 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int4 extractBits_fb850f() {
+  int4 arg_0 = (1).xxxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int4 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int4 v_4 = (((v_3 < 32u)) ? ((v << uint4((v_3).xxxx))) : ((0).xxxx));
+  int4 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint4(((v_3 + v_2)).xxxx))) : (((v_4 >> (31u).xxxx) >> (1u).xxxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store4(0u, asuint(extractBits_fb850f()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store4(0u, asuint(extractBits_fb850f()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_fb850f();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+
diff --git a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.fxc.hlsl b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.fxc.hlsl
index abcc822..ab78a9f 100644
--- a/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.fxc.hlsl
+++ b/test/tint/builtins/gen/var/extractBits/fb850f.wgsl.expected.ir.fxc.hlsl
@@ -1,11 +1,50 @@
-SKIP: FAILED
+struct VertexOutput {
+  float4 pos;
+  int4 prevent_dce;
+};
 
-..\..\src\tint\lang\core\ir\transform\builtin_polyfill.cc:407 internal compiler error: TINT_UNIMPLEMENTED extractBits polyfill level
-********************************************************************
-*  The tint shader compiler has encountered an unexpected error.   *
-*                                                                  *
-*  Please help us fix this issue by submitting a bug report at     *
-*  crbug.com/tint with the source program that triggered the bug.  *
-********************************************************************
+struct vertex_main_outputs {
+  nointerpolation int4 VertexOutput_prevent_dce : TEXCOORD0;
+  float4 VertexOutput_pos : SV_Position;
+};
 
-tint executable returned error: exit status 0xc000001d
+
+RWByteAddressBuffer prevent_dce : register(u0);
+int4 extractBits_fb850f() {
+  int4 arg_0 = (1).xxxx;
+  uint arg_1 = 1u;
+  uint arg_2 = 1u;
+  int4 v = arg_0;
+  uint v_1 = arg_2;
+  uint v_2 = min(arg_1, 32u);
+  uint v_3 = (32u - min(32u, (v_2 + v_1)));
+  int4 v_4 = (((v_3 < 32u)) ? ((v << uint4((v_3).xxxx))) : ((0).xxxx));
+  int4 res = ((((v_3 + v_2) < 32u)) ? ((v_4 >> uint4(((v_3 + v_2)).xxxx))) : (((v_4 >> (31u).xxxx) >> (1u).xxxx)));
+  return res;
+}
+
+void fragment_main() {
+  prevent_dce.Store4(0u, asuint(extractBits_fb850f()));
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+  prevent_dce.Store4(0u, asuint(extractBits_fb850f()));
+}
+
+VertexOutput vertex_main_inner() {
+  VertexOutput tint_symbol = (VertexOutput)0;
+  tint_symbol.pos = (0.0f).xxxx;
+  tint_symbol.prevent_dce = extractBits_fb850f();
+  VertexOutput v_5 = tint_symbol;
+  return v_5;
+}
+
+vertex_main_outputs vertex_main() {
+  VertexOutput v_6 = vertex_main_inner();
+  VertexOutput v_7 = v_6;
+  VertexOutput v_8 = v_6;
+  vertex_main_outputs v_9 = {v_8.prevent_dce, v_7.pos};
+  return v_9;
+}
+