guppylang icon indicating copy to clipboard operation
guppylang copied to clipboard

Use True/False constants for cfg branching if known at compile time

Open ss2165 opened this issue 1 year ago • 2 comments

avoid needless Tag(0, MakeTuple()) calls

ss2165 avatar Jan 22 '24 16:01 ss2165

This Tag(0, MakeTuple()) is also needed if there is only a single successor. Do we also want to use a constant in that case?

If the True/False value of a branch is known at compile-time, I think an even better solution would be to just remove the unreachable branch. This should also make our program analysis a bit smarter

mark-koch avatar Jan 24 '24 10:01 mark-koch

This Tag(0, MakeTuple()) is also needed if there is only a single successor. Do we also want to use a constant in that case?

Yes

If the True/False value of a branch is known at compile-time, I think an even better solution would be to just remove the unreachable branch.

Perhaps, but any HUGR compiler should do that as a normalisation pass pretty early on

ss2165 avatar Jan 24 '24 10:01 ss2165