]> git.lizzy.rs Git - rust.git/commit
MatchBranchSimplification: fix equal const bool assignments
authorTomasz Miąsko <tomasz.miasko@gmail.com>
Sat, 15 Aug 2020 00:00:00 +0000 (00:00 +0000)
committerTomasz Miąsko <tomasz.miasko@gmail.com>
Sat, 15 Aug 2020 00:00:00 +0000 (00:00 +0000)
commit1fe2e2941d93da397c8ace5f410c0ab3dc5a3049
treed0dc222ef5e016c57c05e9bdc163adffa49e59ea
parent4fae04968eccb8797000b5a42760005b35504136
MatchBranchSimplification: fix equal const bool assignments

The match branch simplification is applied when target blocks contain
statements that are either equal or perform a const bool assignment with
different values to the same place.

Previously, when constructing new statements, only statements from a
single block had been examined. This lead to a misoptimization when
statements are equal because the assign the *same* const bool value to
the same place.

Fix the issue by examining statements from both blocks when deciding on
replacement.
src/librustc_mir/transform/match_branches.rs
src/test/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff.32bit [new file with mode: 0644]
src/test/mir-opt/matches_reduce_branches.bar.MatchBranchSimplification.diff.64bit [new file with mode: 0644]
src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff.32bit
src/test/mir-opt/matches_reduce_branches.foo.MatchBranchSimplification.diff.64bit
src/test/mir-opt/matches_reduce_branches.rs