@@ -2398,6 +2398,53 @@ def test_replace_opcode_uop_body_copied_in_complex(self):
23982398 """
23992399 self .run_cases_test (input , input2 , output )
24002400
2401+ def test_replace_opcode_escaping_uop_body_copied_in_complex (self ):
2402+ input = """
2403+ pure op(OP, (foo -- res)) {
2404+ if (foo) {
2405+ res = ESCAPING_CODE(foo);
2406+ }
2407+ else {
2408+ res = 1;
2409+ }
2410+ }
2411+ """
2412+ input2 = """
2413+ op(OP, (foo -- res)) {
2414+ REPLACE_OPCODE_IF_EVALUATES_PURE(foo);
2415+ res = sym_new_known(ctx, foo);
2416+ }
2417+ """
2418+ output = """
2419+ case OP: {
2420+ JitOptRef foo;
2421+ JitOptRef res;
2422+ foo = stack_pointer[-1];
2423+ if (
2424+ sym_is_safe_const(ctx, foo)
2425+ ) {
2426+ JitOptRef foo_sym = foo;
2427+ _PyStackRef foo = sym_get_const_as_stackref(ctx, foo_sym);
2428+ _PyStackRef res_stackref;
2429+ /* Start of uop copied from bytecodes for constant evaluation */
2430+ if (foo) {
2431+ res_stackref = ESCAPING_CODE(foo);
2432+ }
2433+ else {
2434+ res_stackref = 1;
2435+ }
2436+ /* End of uop copied from bytecodes for constant evaluation */
2437+ res = sym_new_const_steal(ctx, PyStackRef_AsPyObjectSteal(res_stackref));
2438+ stack_pointer[-1] = res;
2439+ break;
2440+ }
2441+ res = sym_new_known(ctx, foo);
2442+ stack_pointer[-1] = res;
2443+ break;
2444+ }
2445+ """
2446+ self .run_cases_test (input , input2 , output )
2447+
24012448 def test_replace_opocode_uop_reject_array_effects (self ):
24022449 input = """
24032450 pure op(OP, (foo[2] -- res)) {
0 commit comments