@@ -396,6 +396,21 @@ dummy_func(void) {
396396 REPLACE_OPCODE_IF_EVALUATES_PURE (left , right , res );
397397 }
398398
399+ op (_BINARY_OP_ADD_INT , (left , right -- res , l , r )) {
400+ if (PyJitRef_IsUnique (left )) {
401+ REPLACE_OP (this_instr , _BINARY_OP_ADD_INT_INPLACE , 0 , 0 );
402+ }
403+ else if (PyJitRef_IsUnique (right )) {
404+ REPLACE_OP (this_instr , _BINARY_OP_ADD_INT_INPLACE_RIGHT , 0 , 0 );
405+ }
406+ // Result may be a unique compact int or a cached small int
407+ // at runtime. Mark as unique; inplace ops verify at runtime.
408+ res = PyJitRef_MakeUnique (sym_new_compact_int (ctx ));
409+ l = left ;
410+ r = right ;
411+ REPLACE_OPCODE_IF_EVALUATES_PURE (left , right , res );
412+ }
413+
399414 op (_BINARY_OP_ADD_FLOAT , (left , right -- res , l , r )) {
400415 if (PyJitRef_IsUnique (left )) {
401416 ADD_OP (_BINARY_OP_ADD_FLOAT_INPLACE , 0 , 0 );
@@ -432,6 +447,19 @@ dummy_func(void) {
432447 res = PyJitRef_MakeUnique (sym_new_type (ctx , & PyFloat_Type ));
433448 }
434449
450+ op (_BINARY_OP_SUBTRACT_INT , (left , right -- res , l , r )) {
451+ if (PyJitRef_IsUnique (left )) {
452+ REPLACE_OP (this_instr , _BINARY_OP_SUBTRACT_INT_INPLACE , 0 , 0 );
453+ }
454+ else if (PyJitRef_IsUnique (right )) {
455+ REPLACE_OP (this_instr , _BINARY_OP_SUBTRACT_INT_INPLACE_RIGHT , 0 , 0 );
456+ }
457+ res = PyJitRef_MakeUnique (sym_new_compact_int (ctx ));
458+ l = left ;
459+ r = right ;
460+ REPLACE_OPCODE_IF_EVALUATES_PURE (left , right , res );
461+ }
462+
435463 op (_BINARY_OP_MULTIPLY_FLOAT , (left , right -- res , l , r )) {
436464 if (PyJitRef_IsUnique (left )) {
437465 ADD_OP (_BINARY_OP_MULTIPLY_FLOAT_INPLACE , 0 , 0 );
0 commit comments