Skip to content

Commit 142eff4

Browse files
committed
Change to switch in predicate narrowing
1 parent 4601243 commit 142eff4

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

Python/optimizer_symbols.c

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -875,16 +875,22 @@ _Py_uop_sym_apply_predicate_narrowing(JitOptContext *ctx, JitOptRef ref, bool br
875875
bool lhs_is_const = _Py_uop_sym_is_const(ctx, lhs_ref);
876876
bool rhs_is_const = _Py_uop_sym_is_const(ctx, rhs_ref);
877877

878-
if (pred.kind == JIT_PRED_IS && (lhs_is_const || rhs_is_const)) {
879-
JitOptRef subject_ref = lhs_is_const ? rhs_ref : lhs_ref;
880-
JitOptRef const_ref = lhs_is_const ? lhs_ref : rhs_ref;
878+
switch(pred.kind) {
879+
case JIT_PRED_IS: {
880+
if (!lhs_is_const && !rhs_is_const) {
881+
break;
882+
}
883+
JitOptRef subject_ref = lhs_is_const ? rhs_ref : lhs_ref;
884+
JitOptRef const_ref = lhs_is_const ? lhs_ref : rhs_ref;
881885

882-
PyObject *const_val = _Py_uop_sym_get_const(ctx, const_ref);
883-
if (const_val == NULL) {
884-
return;
886+
PyObject *const_val = _Py_uop_sym_get_const(ctx, const_ref);
887+
if (const_val == NULL) {
888+
break;
889+
}
890+
_Py_uop_sym_set_const(ctx, subject_ref, const_val);
891+
assert(_Py_uop_sym_is_const(ctx, subject_ref));
892+
break;
885893
}
886-
_Py_uop_sym_set_const(ctx, subject_ref, const_val);
887-
assert(_Py_uop_sym_is_const(ctx, subject_ref));
888894
}
889895
}
890896

0 commit comments

Comments
 (0)