about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-03-19 15:17:03 +0100
committerGitHub <noreply@github.com>2019-03-19 15:17:03 +0100
commit7f7829fa8f917b584c38ed0f0ec03ebaa4e2e1f0 (patch)
tree629101116811e4754e95aadc38f9e9a3dd60b888
parenta3581aca02645342f8aa5d944b2e335827419795 (diff)
parentab41023fd49ef7776b6bf50be113e4063312a7c5 (diff)
downloadrust-7f7829fa8f917b584c38ed0f0ec03ebaa4e2e1f0.tar.gz
rust-7f7829fa8f917b584c38ed0f0ec03ebaa4e2e1f0.zip
Rollup merge of #59290 - oli-obk:trivial_move_prop, r=davidtwco
Run branch cleanup after copy prop

This is preliminary work for https://github.com/rust-lang/rust/pull/59288#issuecomment-474277172 which gets rid of `if` in the HIR.

cc @rust-lang/wg-mir-opt 	@Centril
-rw-r--r--src/librustc_mir/transform/mod.rs1
-rw-r--r--src/test/mir-opt/simplify_match.rs22
2 files changed, 23 insertions, 0 deletions
diff --git a/src/librustc_mir/transform/mod.rs b/src/librustc_mir/transform/mod.rs
index 0cd2cecf39c..8df0d72407b 100644
--- a/src/librustc_mir/transform/mod.rs
+++ b/src/librustc_mir/transform/mod.rs
@@ -285,6 +285,7 @@ fn optimized_mir<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> &'tcx
         &simplify_branches::SimplifyBranches::new("after-const-prop"),
         &deaggregator::Deaggregator,
         &copy_prop::CopyPropagation,
+        &simplify_branches::SimplifyBranches::new("after-copy-prop"),
         &remove_noop_landing_pads::RemoveNoopLandingPads,
         &simplify::SimplifyCfg::new("final"),
         &simplify::SimplifyLocals,
diff --git a/src/test/mir-opt/simplify_match.rs b/src/test/mir-opt/simplify_match.rs
new file mode 100644
index 00000000000..0192aa01d01
--- /dev/null
+++ b/src/test/mir-opt/simplify_match.rs
@@ -0,0 +1,22 @@
+fn main() {
+    match { let x = false; x } {
+        true => println!("hello world!"),
+        false => {},
+    }
+}
+
+// END RUST SOURCE
+// START rustc.main.SimplifyBranches-after-copy-prop.before.mir
+// bb0: {
+//     ...
+//     switchInt(const false) -> [false: bb3, otherwise: bb1];
+// }
+// bb1: {
+// END rustc.main.SimplifyBranches-after-copy-prop.before.mir
+// START rustc.main.SimplifyBranches-after-copy-prop.after.mir
+// bb0: {
+//     ...
+//     goto -> bb3;
+// }
+// bb1: {
+// END rustc.main.SimplifyBranches-after-copy-prop.after.mir