Title: Jump-To-Jump elimination could be more aggressive. · Issue #93223 · python/cpython · GitHub
Open Graph Title: Jump-To-Jump elimination could be more aggressive. · Issue #93223 · python/cpython
X Title: Jump-To-Jump elimination could be more aggressive. · Issue #93223 · python/cpython
Description: Example: def f(): for i in range(5): if i > 3: print(i) 1 0 RESUME 0 2 2 LOAD_GLOBAL 1 (NULL + range) 14 LOAD_CONST 1 (5) 16 CALL 1 26 GET_ITER >> 28 FOR_ITER 21 (to 72) 30 STORE_FAST 0 (i) 3 32 LOAD_FAST 0 (i) 34 LOAD_CONST 2 (3) 36 COM...
Open Graph Description: Example: def f(): for i in range(5): if i > 3: print(i) 1 0 RESUME 0 2 2 LOAD_GLOBAL 1 (NULL + range) 14 LOAD_CONST 1 (5) 16 CALL 1 26 GET_ITER >> 28 FOR_ITER 21 (to 72) 30 STORE_FAST 0 (i) 3 32 LO...
X Description: Example: def f(): for i in range(5): if i > 3: print(i) 1 0 RESUME 0 2 2 LOAD_GLOBAL 1 (NULL + range) 14 LOAD_CONST 1 (5) 16 CALL 1 26 GET_ITER >> 28 FOR_ITER 21 (to 72) 30 STORE_FAST 0 (i...
Opengraph URL: https://github.com/python/cpython/issues/93223
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Jump-To-Jump elimination could be more aggressive.","articleBody":"Example:\r\n\r\n```python\r\ndef f():\r\n for i in range(5):\r\n if i \u003e 3:\r\n print(i)\r\n```\r\n\r\n```\r\n 1 0 RESUME 0\r\n\r\n 2 2 LOAD_GLOBAL 1 (NULL + range)\r\n 14 LOAD_CONST 1 (5)\r\n 16 CALL 1\r\n 26 GET_ITER\r\n \u003e\u003e 28 FOR_ITER 21 (to 72)\r\n 30 STORE_FAST 0 (i)\r\n\r\n 3 32 LOAD_FAST 0 (i)\r\n 34 LOAD_CONST 2 (3)\r\n 36 COMPARE_OP 4 (\u003e)\r\n 42 POP_JUMP_FORWARD_IF_FALSE 13 (to 70) \u003c--------- could be BACKWARD to 28\r\n\r\n 4 44 LOAD_GLOBAL 3 (NULL + print)\r\n 56 LOAD_FAST 0 (i)\r\n 58 CALL 1\r\n 68 POP_TOP\r\n \u003e\u003e 70 JUMP_BACKWARD 22 (to 28)\r\n\r\n 2 \u003e\u003e 72 LOAD_CONST 0 (None)\r\n 74 RETURN_VALUE\r\n```\r\n\r\n\r\nSomething like this should suffice:\r\n```diff\r\n static bool\r\n jump_thread(struct instr *inst, struct instr *target, int opcode)\r\n {\r\n assert(!IS_VIRTUAL_OPCODE(opcode) || IS_VIRTUAL_JUMP_OPCODE(opcode));\r\n assert(is_jump(inst));\r\n assert(is_jump(target));\r\n // bpo-45773: If inst-\u003ei_target == target-\u003ei_target, then nothing actually\r\n // changes (and we fall into an infinite loop):\r\n- if (inst-\u003ei_lineno == target-\u003ei_lineno \u0026\u0026\r\n+ if ((inst-\u003ei_lineno == target-\u003ei_lineno || target-\u003ei_lineno == -1) \u0026\u0026\r\n inst-\u003ei_target != target-\u003ei_target)\r\n {\r\n inst-\u003ei_target = target-\u003ei_target;\r\n inst-\u003ei_opcode = opcode;\r\n return true;\r\n }\r\n return false;\r\n }\r\n```\r\n\r\ncc @markshannon @iritkatriel @brandtbucher ","author":{"url":"https://github.com/sweeneyde","@type":"Person","name":"sweeneyde"},"datePublished":"2022-05-25T16:57:34.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/93223/cpython/issues/93223"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:16d80a10-ce1d-0c1a-45fa-84a6fc59eaa1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | ADC8:134C26:1BDEB8B:2500E47:696AF73C |
| html-safe-nonce | 1865f1164987b5bf56bf286a227702fdb024071e5f0cefee1593ac54a433f773 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBREM4OjEzNEMyNjoxQkRFQjhCOjI1MDBFNDc6Njk2QUY3M0MiLCJ2aXNpdG9yX2lkIjoiODYyOTAzNTg2ODY1NzIxOTM4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 46bed2c915277cd3aae795f69160e586db48a4f2422fbbbd7b8a1204362e729b |
| hovercard-subject-tag | issue:1248400926 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/93223/issue_layout |
| twitter:image | https://opengraph.githubassets.com/2b0dcef5fa012eb19b9dcda198890afe7e7f2d9fbe63dc25f911e2fe2e419537/python/cpython/issues/93223 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/2b0dcef5fa012eb19b9dcda198890afe7e7f2d9fbe63dc25f911e2fe2e419537/python/cpython/issues/93223 |
| og:image:alt | Example: def f(): for i in range(5): if i > 3: print(i) 1 0 RESUME 0 2 2 LOAD_GLOBAL 1 (NULL + range) 14 LOAD_CONST 1 (5) 16 CALL 1 26 GET_ITER >> 28 FOR_ITER 21 (to 72) 30 STORE_FAST 0 (i) 3 32 LO... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sweeneyde |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width