Skip to content

Commit 74e1737

Browse files
authored
[mypyc] Mark magic-overlapping error handler branches as rare (#13525)
This might slightly improve performance when using native ints, and it's consistent with how other error handler branches are treated as rare. Now the generated error handling code when calling a function that returns a native int looks something like this (the `unlikely(...)` part is new): ``` cpy_r_r0 = CPyDef_f(); cpy_r_r1 = cpy_r_r0 == -113; if (unlikely(cpy_r_r1)) goto CPyL2; ```
1 parent 9e14aba commit 74e1737

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypyc/transform/exceptions.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ def split_blocks_at_errors(
103103
new_block2 = BasicBlock()
104104
new_blocks.append(new_block2)
105105
branch = Branch(
106-
comp, true_label=new_block2, false_label=new_block, op=Branch.BOOL
106+
comp,
107+
true_label=new_block2,
108+
false_label=new_block,
109+
op=Branch.BOOL,
110+
rare=True,
107111
)
108112
cur_block.ops.append(branch)
109113
cur_block = new_block2

0 commit comments

Comments
 (0)