I just noticed that in some cases FXC generates PHI nodes which mention the same origin block more than once. For example, ```hlsl struct PSInput { float4 color : COLOR; };
float4 main(PSInput input) : SV_TARGET { float y = 0; switch (input.color.x) { case 0: y = 100; break; case 1: y = 101; break; case 2: break; case 3: break; case 4: y = 104; break; case 5: y = 105; break; default: y = 200; break; }
input.color.y = y;
return input.color; } ``` compiles to ``` define void @main() { %1 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 0, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) %2 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 2, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) %3 = call float @dx.op.loadInput.f32(i32 4, i32 0, i32 0, i8 3, i32 undef) ; LoadInput(inputSigId,rowIndex,colIndex,gsVertexAxis) %4 = fptosi float %1 to i32 switch i32 %4, label %9 [ i32 0, label %5 i32 1, label %6 i32 2, label %10 i32 3, label %10 i32 4, label %7 i32 5, label %8 ]
; <label>:5 ; preds = %0 br label %10
; <label>:6 ; preds = %0 br label %10
; <label>:7 ; preds = %0 br label %10
; <label>:8 ; preds = %0 br label %10
; <label>:9 ; preds = %0 br label %10
; <label>:10 ; preds = %9, %8, %7, %6, %5, %0, %0 %11 = phi float [ 2.000000e+02, %9 ], [ 1.050000e+02, %8 ], [ 1.040000e+02, %7 ], [ 0.000000e+00, %0 ], [ 0.000000e+00, %0 ], [ 1.010000e+02, %6 ], [ 1.000000e+02, %5 ] call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 0, float %1) ; StoreOutput(outputSigId,rowIndex,colIndex,value) call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 1, float %11) ; StoreOutput(outputSigId,rowIndex,colIndex,value) call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 2, float %2) ; StoreOutput(outputSigId,rowIndex,colIndex,value) call void @dx.op.storeOutput.f32(i32 5, i32 0, i32 0, i8 3, float %3) ; StoreOutput(outputSigId,rowIndex,colIndex,value) ret void } ```
As you can see, `%0` is duplicated both in the preds list and in the PHI node. This feels quite broken and it's understandably forbidden by SPIR-V. Could you please add my (or a similar) source code to a shader runner test and implement a deduplication logic, emitting an error if values of duplicated PHI entries do not match?