]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-131798: Small improvements to `remove_unneeded_uops` (GH-134554)
authorTomas R. <tomas.roun8@gmail.com>
Fri, 23 May 2025 12:48:45 +0000 (08:48 -0400)
committerGitHub <noreply@github.com>
Fri, 23 May 2025 12:48:45 +0000 (20:48 +0800)
Improve remove_unneeded_uops

Python/optimizer_analysis.c

index 851e1efa0497af6b52fc0f942625b4e2c5282ef2..6a7df233819b9cd3f06260b7c559a3d103a69ea4 100644 (file)
@@ -558,6 +558,7 @@ const uint16_t op_without_push[MAX_UOP_ID + 1] = {
 const bool op_skip[MAX_UOP_ID + 1] = {
     [_NOP] = true,
     [_CHECK_VALIDITY] = true,
+    [_CHECK_PERIODIC] = true,
     [_SET_IP] = true,
 };
 
@@ -617,7 +618,7 @@ remove_unneeded_uops(_PyUOpInstruction *buffer, int buffer_size)
                     while (op_skip[last->opcode]) {
                         last--;
                     }
-                    if (op_without_push[last->opcode]) {
+                    if (op_without_push[last->opcode] && op_without_pop[opcode]) {
                         last->opcode = op_without_push[last->opcode];
                         opcode = buffer[pc].opcode = op_without_pop[opcode];
                         if (op_without_pop[last->opcode]) {