microsoft / qsharp

Azure Quantum Development Kit, including the Q# programming language, resource estimator, and Quantum Katas
https://microsoft.github.io/qsharp/
MIT License
369 stars 73 forks source link

Fix panic when creating unneeded Phi node #1527

Closed swernli closed 1 month ago

swernli commented 1 month ago

This fixes an issue where a mutable variable A used only in one scope and not across any others is set to a different mutable variable B that spans multiple scopes, including scopes that are not dominated by variable B. Variables like B do not need phi nodes as they are assumed to be unused in later blocks, and any actual usage in later blocks will be caught by the SSA check pass by using the dominator tree.

github-actions[bot] commented 1 month ago

Benchmark for 422f4d8

Click to view benchmark | Test | Base | PR | % | |------|--------------|------------------|---| | Array append evaluation | 344.3±1.50µs | 343.6±3.76µs | -0.20% | | Array literal evaluation | 189.3±0.92µs | 189.9±1.01µs | +0.32% | | Array update evaluation | 433.5±28.25µs | **428.7±1.58µs** | **-1.11%** | | Core + Standard library compilation | **16.7±0.12ms** | 17.3±0.74ms | **+3.59%** | | Deutsch-Jozsa evaluation | 5.1±0.08ms | 5.1±0.05ms | 0.00% | | Large file parity evaluation | **33.7±0.10ms** | 33.8±0.09ms | **+0.30%** | | Large input file compilation | 11.4±0.11ms | 11.4±0.14ms | 0.00% | | Large input file compilation (interpreter) | 44.5±1.32ms | 43.8±0.93ms | -1.57% | | Large nested iteration | 33.7±0.40ms | 33.7±0.52ms | 0.00% | | Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample | 1554.1±30.12µs | 1552.0±29.34µs | -0.14% | | Perform Runtime Capabilities Analysis (RCA) on large file sample | 7.8±0.34ms | **7.7±0.07ms** | **-1.28%** | | Perform Runtime Capabilities Analysis (RCA) on teleport sample | 1416.5±36.49µs | 1412.0±35.81µs | -0.32% | | Perform Runtime Capabilities Analysis (RCA) on the core and std libraries | 27.5±0.19ms | 27.6±0.17ms | +0.36% | | Teleport evaluation | 87.0±3.46µs | 89.7±4.85µs | +3.10% |