You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the following example, a programmer would logically expect the compiler to generate two switches. Unfortunately, this is not what happens, as one switch will become embedded inside each and every branch of the other (thereby creating 1 + 5 switches). See the thorin IR at the bottom of this post for reference.
The solution to this problem would be (in my opinion), to stop using the branch() and match() intrinsics, and use a combination of select + jump (and maybe a new primop that selects between more than two options) instead (which is what we were doing at some point before introducing branch()). This will indeed complicate a bit code generation but is also more natural (the IR is then smaller) and I don't think it is too hard to implement.
We used to do the select + jump trick back in the days of yore. IMHO the branch intrinsic is a bit more concise and easier to work with. At least I never found my self looking back to select + jump. That being said, I don't quite see why select + jump would help?
The explicit control flow in the match (and therefore also in the branch()) intrinsic functions will duplicate code when specialization:
In the following example, a programmer would logically expect the compiler to generate two switches. Unfortunately, this is not what happens, as one switch will become embedded inside each and every branch of the other (thereby creating 1 + 5 switches). See the thorin IR at the bottom of this post for reference.
The solution to this problem would be (in my opinion), to stop using the branch() and match() intrinsics, and use a combination of select + jump (and maybe a new primop that selects between more than two options) instead (which is what we were doing at some point before introducing branch()). This will indeed complicate a bit code generation but is also more natural (the IR is then smaller) and I don't think it is too hard to implement.
Module before PE (2 switches):
Module after PE (6 switches):
The text was updated successfully, but these errors were encountered: