Skip to content

Commit 5eeec53

Browse files
committed
feat: allow for cross switch int transition
1 parent 6e14a48 commit 5eeec53

3 files changed

Lines changed: 8 additions & 9 deletions

File tree

libs/@local/hashql/mir/src/pass/execution/terminator_placement/mod.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -393,13 +393,9 @@ impl PopulateEdgeMatrix {
393393
terminator: &TerminatorKind,
394394
) {
395395
match terminator {
396-
TerminatorKind::Goto(_) => {
396+
TerminatorKind::Goto(_) | TerminatorKind::SwitchInt(_) => {
397397
self.add_goto_transitions(matrix);
398398
}
399-
TerminatorKind::SwitchInt(_) => {
400-
// SwitchInt does not allow additional cross-backend transitions
401-
// due to complexity of coordinating branches across backends.
402-
}
403399
TerminatorKind::GraphRead(_) => {
404400
self.restrict_to_interpreter_only(matrix);
405401
}

libs/@local/hashql/mir/src/pass/execution/terminator_placement/tests.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ fn goto_allows_cross_backend_non_postgres() {
225225
}
226226

227227
#[test]
228-
fn switchint_blocks_cross_backend() {
228+
fn switchint_allows_cross_backend() {
229229
let heap = Heap::new();
230230
let interner = Interner::new(&heap);
231231
let env = Environment::new(&heap);
@@ -263,7 +263,10 @@ fn switchint_blocks_cross_backend() {
263263
);
264264

265265
let matrix = costs.of(BasicBlockId::new(0))[0];
266-
assert_eq!(matrix.get(TargetId::Interpreter, TargetId::Embedding), None);
266+
assert_eq!(
267+
matrix.get(TargetId::Interpreter, TargetId::Embedding),
268+
Some(cost!(5))
269+
);
267270
// data transfer (1) + backend switch E->I (4) = 5
268271
assert_eq!(
269272
matrix.get(TargetId::Embedding, TargetId::Interpreter),
@@ -336,7 +339,7 @@ fn switchint_edge_targets_are_branch_specific() {
336339
assert!(
337340
second
338341
.get(TargetId::Interpreter, TargetId::Embedding)
339-
.is_none()
342+
.is_some()
340343
);
341344
assert!(
342345
second

libs/@local/hashql/mir/tests/ui/pass/execution/terminator_placement/terminator_placement_snapshot.snap

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)