Fix some SPIR-V disassembled if()s exiting too early

* If the merge block is the main body of the if that implies there is fall-
  through to the else case, it is more confusing but equivalent to putting the
  merge block as the else case as the merge block doesn't have to be after the if.
This commit is contained in:
baldurk
2026-07-15 11:03:08 +01:00
parent 1f3334d358
commit b013798e32
@@ -789,6 +789,20 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint,
RDCASSERTEQUAL(nextit.opcode(), Op::Label);
OpLabel decodedlabel(nextit);
// if the next label was the merge target that implies that we will eventually go from
// that flow into the other case, not a strict if/else but an if() ...
// For our purposes use the other label as merge target since that's when we will clean up the if()
if(decodedbranch.trueLabel == decodedlabel.result &&
decodedbranch.trueLabel == cfg.mergeTarget)
{
cfg.mergeTarget = decodedbranch.falseLabel;
}
else if(decodedbranch.falseLabel == decodedlabel.result &&
decodedbranch.falseLabel == cfg.mergeTarget)
{
cfg.mergeTarget = decodedbranch.trueLabel;
}
if(decodedbranch.trueLabel == decodedlabel.result ||
decodedbranch.falseLabel == decodedlabel.result)
{