diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c
index aac4e4c042d01638dd539d01ff7e9a1472d39fdd..e95eaa39d8ced498dd5edcf49ad794d69a594301 100644
--- a/libs/vkd3d-shader/hlsl_codegen.c
+++ b/libs/vkd3d-shader/hlsl_codegen.c
@@ -1638,14 +1638,14 @@ static void copy_propagation_invalidate_variable_from_deref_recurse(struct hlsl_
                 return;
 
             copy_propagation_invalidate_variable_from_deref_recurse(ctx, var_def, deref, subtype,
-                    depth + 1, index * subtype_comp_count, writemask, time);
+                    depth + 1, comp_start + index * subtype_comp_count, writemask, time);
         }
         else
         {
             for (i = 0; i < hlsl_type_element_count(type); ++i)
             {
                 copy_propagation_invalidate_variable_from_deref_recurse(ctx, var_def, deref, subtype,
-                        depth + 1, i * subtype_comp_count, writemask, time);
+                        depth + 1, comp_start + i * subtype_comp_count, writemask, time);
             }
         }
     }
diff --git a/tests/hlsl/hard-copy-prop.shader_test b/tests/hlsl/hard-copy-prop.shader_test
index 3af552fadaf6473ad0ebb0d573f9d16b36662876..0637589227317e449407f29a1ecf75974c1f7127 100644
--- a/tests/hlsl/hard-copy-prop.shader_test
+++ b/tests/hlsl/hard-copy-prop.shader_test
@@ -205,3 +205,21 @@ float4 main() : sv_target
 
     return 0;
 }
+
+[pixel shader todo(sm<4)]
+float a;
+
+float4 main() : sv_target
+{
+    float arr[2][2] = {1, 2, 3, 4};
+
+    if (a > 0)
+        arr[1][1] = 5;
+
+    return float4(arr[0][0], arr[0][1], arr[1][0], arr[1][1]);
+}
+
+[test]
+uniform 0 float 11.0
+todo(sm<4) draw quad
+probe (0, 0) rgba(1, 2, 3, 5)