rust icon indicating copy to clipboard operation
rust copied to clipboard

Transforms match into an assignment statement

Open DianQK opened this issue 5 months ago • 13 comments

Fixes #106459.

We should be able to do some similar transformations, like enum to enum.

r? mir-opt

DianQK avatar Feb 03 '24 14:02 DianQK

The job x86_64-gnu-llvm-16 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
GITHUB_ENV=/home/runner/work/_temp/_runner_file_commands/set_env_8bd10f8b-6942-4dc7-9002-758357d4a44d
GITHUB_EVENT_NAME=pull_request
GITHUB_EVENT_PATH=/home/runner/work/_temp/_github_workflow/event.json
GITHUB_GRAPHQL_URL=https://api.github.com/graphql
GITHUB_HEAD_REF=simplify-switch-int
GITHUB_JOB=pr
GITHUB_PATH=/home/runner/work/_temp/_runner_file_commands/add_path_8bd10f8b-6942-4dc7-9002-758357d4a44d
GITHUB_REF=refs/pull/120614/merge
GITHUB_REF_NAME=120614/merge
GITHUB_REF_PROTECTED=false
---
#12 writing image sha256:21fe34ec4e106740934382c1eb63838ae6683887d5de1918b8c6b991fa7c8604 done
#12 naming to docker.io/library/rust-ci done
#12 DONE 10.0s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-16]
##[group]Clock drift check
  local time: Sat Feb  3 14:50:25 UTC 2024
  network time: Sat, 03 Feb 2024 14:50:25 GMT
  network time: Sat, 03 Feb 2024 14:50:25 GMT
##[endgroup]
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-16', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--set', 'build.optimized-compiler-builtins', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-16/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---
##[endgroup]
Testing GCC stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling y v0.1.0 (/checkout/compiler/rustc_codegen_gcc/build_system)
    Finished release [optimized] target(s) in 1.36s
     Running `/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-codegen/x86_64-unknown-linux-gnu/release/y test --use-system-gcc --use-backend gcc --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc --release --no-default-features --mini-tests --std-tests`
Using system GCC
Using system GCC
[BUILD] example
[AOT] mini_core_hello_world
/checkout/obj/build/x86_64-unknown-linux-gnu/stage1-tools/cg_gcc/mini_core_hello_world
abc

rust-log-analyzer avatar Feb 03 '24 15:02 rust-log-analyzer

@bors try @rust-timer queue

saethlin avatar Feb 04 '24 01:02 saethlin

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

rust-timer avatar Feb 04 '24 01:02 rust-timer

:hourglass: Trying commit 7a476356b92be052317d920dfa6302653cd72f8d with merge eea65f2f4affd04b3b0fd5127c7e0951a2747136...

bors avatar Feb 04 '24 01:02 bors

:sunny: Try build successful - checks-actions Build commit: eea65f2f4affd04b3b0fd5127c7e0951a2747136 (eea65f2f4affd04b3b0fd5127c7e0951a2747136)

bors avatar Feb 04 '24 02:02 bors

Queued eea65f2f4affd04b3b0fd5127c7e0951a2747136 with parent b11fbfbf351b94c7eecf9e6749a4544a6d4717fa, future comparison URL. There are currently 0 preceding artifacts in the queue. It will probably take at least ~1.2 hours until the benchmark run finishes.

rust-timer avatar Feb 04 '24 02:02 rust-timer

Finished benchmarking commit (eea65f2f4affd04b3b0fd5127c7e0951a2747136): comparison URL.

Overall result: no relevant changes - no action needed

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

@bors rollup=never @rustbot label: -S-waiting-on-perf -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
2.1% [1.2%, 3.7%] 7
Regressions ❌
(secondary)
2.9% [2.0%, 4.7%] 20
Improvements ✅
(primary)
-4.1% [-5.0%, -3.1%] 2
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.7% [-5.0%, 3.7%] 9

Cycles

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-6.2% [-7.2%, -5.2%] 6
All ❌✅ (primary) - - 0

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.0% [0.0%, 0.0%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.0% [-0.0%, -0.0%] 4
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.0% [-0.0%, 0.0%] 5

Bootstrap: 659.957s -> 661.541s (0.24%) Artifact size: 308.08 MiB -> 308.11 MiB (0.01%)

rust-timer avatar Feb 04 '24 04:02 rust-timer

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

rustbot avatar Feb 06 '24 14:02 rustbot

:umbrella: The latest upstream changes (presumably #121036) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Feb 13 '24 19:02 bors

Sorry for my late reply. @rustbot ready

DianQK avatar Feb 21 '24 11:02 DianQK

:umbrella: The latest upstream changes (presumably #121370) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Feb 22 '24 19:02 bors

:umbrella: The latest upstream changes (presumably #120268) made this pull request unmergeable. Please resolve the merge conflicts.

bors avatar Mar 08 '24 09:03 bors

@rustbot ready

DianQK avatar Mar 10 '24 14:03 DianQK

@bors r+

cjgillot avatar Apr 07 '24 13:04 cjgillot

:pushpin: Commit 755d9e5c68dc9208e4658c8e44bf8e9aa2726f24 has been approved by cjgillot

It is now in the queue for this repository.

bors avatar Apr 07 '24 13:04 bors

:hourglass: Testing commit 755d9e5c68dc9208e4658c8e44bf8e9aa2726f24 with merge ff94deee6d3626a71fc8942a9fff47d79cb17399...

bors avatar Apr 07 '24 16:04 bors

The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [mir-opt] tests/mir-opt/matches_reduce_branches.rs stdout ----
17 -     }
18 - 
19 -     bb2: {
- -         _0 = const _;
+ -         _0 = const core::num::<impl u128>::MAX;
21 -         goto -> bb6;
23 - 

thread '[mir-opt] tests/mir-opt/matches_reduce_branches.rs' panicked at src/tools/compiletest/src/runtest.rs:4357:21:
thread '[mir-opt] tests/mir-opt/matches_reduce_branches.rs' panicked at src/tools/compiletest/src/runtest.rs:4357:21:
Actual MIR output differs from expected MIR output /checkout/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: <compiletest::runtest::TestCx>::run_revision
   3: compiletest::runtest::run

rust-log-analyzer avatar Apr 07 '24 17:04 rust-log-analyzer

:broken_heart: Test failed - checks-actions

bors avatar Apr 07 '24 17:04 bors

The job x86_64-gnu-llvm-17 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
#16 exporting to docker image format
#16 sending tarball 28.9s done
#16 DONE 41.2s
##[endgroup]
Setting extra environment values for docker:  --env ENABLE_GCC_CODEGEN=1 --env GCC_EXEC_PREFIX=/usr/lib/gcc/
[CI_JOB_NAME=x86_64-gnu-llvm-17]
---
sccache: Starting the server...
##[group]Configure the build
configure: processing command line
configure: 
configure: build.configure-args := ['--build=x86_64-unknown-linux-gnu', '--llvm-root=/usr/lib/llvm-17', '--enable-llvm-link-shared', '--set', 'rust.thin-lto-import-instr-limit=10', '--set', 'change-id=99999999', '--enable-verbose-configure', '--enable-sccache', '--disable-manage-submodules', '--enable-locked-deps', '--enable-cargo-native-static', '--set', 'rust.codegen-units-std=1', '--set', 'dist.compression-profile=balanced', '--dist-compression-formats=xz', '--disable-dist-src', '--release-channel=nightly', '--enable-debug-assertions', '--enable-overflow-checks', '--enable-llvm-assertions', '--set', 'rust.verify-llvm-ir', '--set', 'rust.codegen-backends=llvm,cranelift,gcc', '--set', 'llvm.static-libstdcpp', '--enable-new-symbol-mangling']
configure: target.x86_64-unknown-linux-gnu.llvm-config := /usr/lib/llvm-17/bin/llvm-config
configure: llvm.link-shared     := True
configure: rust.thin-lto-import-instr-limit := 10
configure: change-id            := 99999999
---

---- [mir-opt] tests/mir-opt/matches_reduce_branches.rs stdout ----
17 -     }
18 - 
19 -     bb2: {
- -         _0 = const _;
+ -         _0 = const core::num::<impl u128>::MAX;
21 -         goto -> bb6;
23 - 

thread '[mir-opt] tests/mir-opt/matches_reduce_branches.rs' panicked at src/tools/compiletest/src/runtest.rs:4377:21:
thread '[mir-opt] tests/mir-opt/matches_reduce_branches.rs' panicked at src/tools/compiletest/src/runtest.rs:4377:21:
Actual MIR output differs from expected MIR output /checkout/tests/mir-opt/matches_reduce_branches.match_i128_u128.MatchBranchSimplification.diff


failures:
    [mir-opt] tests/mir-opt/matches_reduce_branches.rs

rust-log-analyzer avatar Apr 08 '24 11:04 rust-log-analyzer

Rebased. :>

DianQK avatar Apr 08 '24 11:04 DianQK

@bors r=cjgillot

WaffleLapkin avatar Apr 08 '24 14:04 WaffleLapkin

:pushpin: Commit f4407370dbb67115bc4acc97dbbdceba0f6d17f3 has been approved by cjgillot

It is now in the queue for this repository.

bors avatar Apr 08 '24 14:04 bors

:hourglass: Testing commit f4407370dbb67115bc4acc97dbbdceba0f6d17f3 with merge 211518e5fb1336de6a4aab45dc1c05f5d83ce856...

bors avatar Apr 08 '24 18:04 bors

:sunny: Test successful - checks-actions Approved by: cjgillot Pushing 211518e5fb1336de6a4aab45dc1c05f5d83ce856 to master...

bors avatar Apr 08 '24 20:04 bors

Finished benchmarking commit (211518e5fb1336de6a4aab45dc1c05f5d83ce856): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.3% [0.3%, 0.3%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.3% [0.3%, 0.3%] 1

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
5.4% [5.4%, 5.4%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 5.4% [5.4%, 5.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
0.1% [0.0%, 0.1%] 5
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-0.1% [-0.1%, -0.1%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 0.0% [-0.1%, 0.1%] 6

Bootstrap: 669.664s -> 668.886s (-0.12%) Artifact size: 318.23 MiB -> 318.49 MiB (0.08%)

rust-timer avatar Apr 08 '24 21:04 rust-timer