Title: compiler can incorrectly optimize a run of stores to the same name preceded by a SWAP · Issue #104615 · python/cpython · GitHub
Open Graph Title: compiler can incorrectly optimize a run of stores to the same name preceded by a SWAP · Issue #104615 · python/cpython
X Title: compiler can incorrectly optimize a run of stores to the same name preceded by a SWAP · Issue #104615 · python/cpython
Description: If the apply_static_swaps optimization in the compiler sees the instruction sequence SWAP 2; STORE_FAST a; STORE_FAST a, it will optimize that by removing the SWAP and swapping the two instructions, resulting in STORE_FAST a; STORE_FAST ...
Open Graph Description: If the apply_static_swaps optimization in the compiler sees the instruction sequence SWAP 2; STORE_FAST a; STORE_FAST a, it will optimize that by removing the SWAP and swapping the two instructions...
X Description: If the apply_static_swaps optimization in the compiler sees the instruction sequence SWAP 2; STORE_FAST a; STORE_FAST a, it will optimize that by removing the SWAP and swapping the two instructions...
Opengraph URL: https://github.com/python/cpython/issues/104615
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"compiler can incorrectly optimize a run of stores to the same name preceded by a SWAP","articleBody":"If the `apply_static_swaps` optimization in the compiler sees the instruction sequence `SWAP 2; STORE_FAST a; STORE_FAST a`, it will optimize that by removing the `SWAP` and swapping the two instructions, resulting in `STORE_FAST a; STORE_FAST a`.\r\n\r\nBut of course, in this case the two instructions are identical, and their ordering matters because they store to the same location. So this change results in the wrong value being stored to `a`.\r\n\r\nThis was exposed by comprehension inlining, since it can result in this bytecode sequence for code in the form `a = [1 for a in [0]]` (where the first `STORE_FAST a` is restoring the previous value of `a` from before the comprehension, if any, and the second `STORE_FAST a` is storing the result of the comprehension to `a`.).\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-104620\n* gh-104636\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/carljm","@type":"Person","name":"carljm"},"datePublished":"2023-05-18T16:18:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/104615/cpython/issues/104615"}
| 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:8cb1d4e6-a7df-a989-3c7d-100b110d109b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D23E:1E165C:9D4F92:D3518C:69697DCE |
| html-safe-nonce | 7a36e01e5baff151077f41db376b4ac61a68edc5682dbda209edbe3846ec8a39 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMjNFOjFFMTY1Qzo5RDRGOTI6RDM1MThDOjY5Njk3RENFIiwidmlzaXRvcl9pZCI6Ijc1MDIyNjAyOTUyOTIyNTU2OTQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 931580c93e0686e857eaad671a8775741f84bced9537b831fead29b1ebe5dba6 |
| hovercard-subject-tag | issue:1715906324 |
| 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/104615/issue_layout |
| twitter:image | https://opengraph.githubassets.com/063255553138524d661f57d6b88f50b3a05a23a29800e158863a9a6d87b44ecb/python/cpython/issues/104615 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/063255553138524d661f57d6b88f50b3a05a23a29800e158863a9a6d87b44ecb/python/cpython/issues/104615 |
| og:image:alt | If the apply_static_swaps optimization in the compiler sees the instruction sequence SWAP 2; STORE_FAST a; STORE_FAST a, it will optimize that by removing the SWAP and swapping the two instructions... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | carljm |
| hostname | github.com |
| expected-hostname | github.com |
| None | f33e4b94c8824ab2b434d82a94139432fb5ebee9df4b75304140ad22508c4a77 |
| 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 | 48f380098b30acbb700b04f1724481ca10d574fc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width