about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorBen Kimock <kimockb@gmail.com>2023-05-06 23:20:58 -0400
committerBen Kimock <kimockb@gmail.com>2023-05-06 23:22:32 -0400
commitff855547f463aecb0c86f8f78ebc605ef097664b (patch)
treeec64c766c0cbefd7c35d2edac9de2b5ae2b26b6c /compiler
parenta77c552485a19245a266bc03c450676c666b605f (diff)
downloadrust-ff855547f463aecb0c86f8f78ebc605ef097664b.tar.gz
rust-ff855547f463aecb0c86f8f78ebc605ef097664b.zip
Rename InstCombine to InstSimplify
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_mir_transform/src/instsimplify.rs (renamed from compiler/rustc_mir_transform/src/instcombine.rs)50
-rw-r--r--compiler/rustc_mir_transform/src/lib.rs4
-rw-r--r--compiler/rustc_mir_transform/src/simplify.rs4
-rw-r--r--compiler/rustc_session/src/options.rs2
4 files changed, 30 insertions, 30 deletions
diff --git a/compiler/rustc_mir_transform/src/instcombine.rs b/compiler/rustc_mir_transform/src/instsimplify.rs
index 432852a1fdd..6bff535586a 100644
--- a/compiler/rustc_mir_transform/src/instcombine.rs
+++ b/compiler/rustc_mir_transform/src/instsimplify.rs
@@ -1,6 +1,6 @@
 //! Performs various peephole optimizations.
 
-use crate::simplify::combine_duplicate_switch_targets;
+use crate::simplify::simplify_duplicate_switch_targets;
 use crate::MirPass;
 use rustc_hir::Mutability;
 use rustc_middle::mir::*;
@@ -10,15 +10,15 @@ use rustc_middle::ty::{self, ParamEnv, SubstsRef, Ty, TyCtxt};
 use rustc_span::symbol::Symbol;
 use rustc_target::abi::FieldIdx;
 
-pub struct InstCombine;
+pub struct InstSimplify;
 
-impl<'tcx> MirPass<'tcx> for InstCombine {
+impl<'tcx> MirPass<'tcx> for InstSimplify {
     fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
         sess.mir_opt_level() > 0
     }
 
     fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
-        let ctx = InstCombineContext {
+        let ctx = InstSimplifyContext {
             tcx,
             local_decls: &body.local_decls,
             param_env: tcx.param_env_reveal_all_normalized(body.source.def_id()),
@@ -27,43 +27,43 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
             for statement in block.statements.iter_mut() {
                 match statement.kind {
                     StatementKind::Assign(box (_place, ref mut rvalue)) => {
-                        ctx.combine_bool_cmp(&statement.source_info, rvalue);
-                        ctx.combine_ref_deref(&statement.source_info, rvalue);
-                        ctx.combine_len(&statement.source_info, rvalue);
-                        ctx.combine_cast(&statement.source_info, rvalue);
+                        ctx.simplify_bool_cmp(&statement.source_info, rvalue);
+                        ctx.simplify_ref_deref(&statement.source_info, rvalue);
+                        ctx.simplify_len(&statement.source_info, rvalue);
+                        ctx.simplify_cast(&statement.source_info, rvalue);
                     }
                     _ => {}
                 }
             }
 
-            ctx.combine_primitive_clone(
+            ctx.simplify_primitive_clone(
                 &mut block.terminator.as_mut().unwrap(),
                 &mut block.statements,
             );
-            ctx.combine_intrinsic_assert(
+            ctx.simplify_intrinsic_assert(
                 &mut block.terminator.as_mut().unwrap(),
                 &mut block.statements,
             );
-            combine_duplicate_switch_targets(block.terminator.as_mut().unwrap());
+            simplify_duplicate_switch_targets(block.terminator.as_mut().unwrap());
         }
     }
 }
 
-struct InstCombineContext<'tcx, 'a> {
+struct InstSimplifyContext<'tcx, 'a> {
     tcx: TyCtxt<'tcx>,
     local_decls: &'a LocalDecls<'tcx>,
     param_env: ParamEnv<'tcx>,
 }
 
-impl<'tcx> InstCombineContext<'tcx, '_> {
-    fn should_combine(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
+impl<'tcx> InstSimplifyContext<'tcx, '_> {
+    fn should_simplify(&self, source_info: &SourceInfo, rvalue: &Rvalue<'tcx>) -> bool {
         self.tcx.consider_optimizing(|| {
-            format!("InstCombine - Rvalue: {:?} SourceInfo: {:?}", rvalue, source_info)
+            format!("InstSimplify - Rvalue: {:?} SourceInfo: {:?}", rvalue, source_info)
         })
     }
 
     /// Transform boolean comparisons into logical operations.
-    fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
+    fn simplify_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
         match rvalue {
             Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
                 let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
@@ -94,7 +94,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
                     _ => None,
                 };
 
-                if let Some(new) = new && self.should_combine(source_info, rvalue) {
+                if let Some(new) = new && self.should_simplify(source_info, rvalue) {
                     *rvalue = new;
                 }
             }
@@ -109,14 +109,14 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
     }
 
     /// Transform "&(*a)" ==> "a".
-    fn combine_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
+    fn simplify_ref_deref(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
         if let Rvalue::Ref(_, _, place) = rvalue {
             if let Some((base, ProjectionElem::Deref)) = place.as_ref().last_projection() {
                 if rvalue.ty(self.local_decls, self.tcx) != base.ty(self.local_decls, self.tcx).ty {
                     return;
                 }
 
-                if !self.should_combine(source_info, rvalue) {
+                if !self.should_simplify(source_info, rvalue) {
                     return;
                 }
 
@@ -129,11 +129,11 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
     }
 
     /// Transform "Len([_; N])" ==> "N".
-    fn combine_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
+    fn simplify_len(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
         if let Rvalue::Len(ref place) = *rvalue {
             let place_ty = place.ty(self.local_decls, self.tcx).ty;
             if let ty::Array(_, len) = *place_ty.kind() {
-                if !self.should_combine(source_info, rvalue) {
+                if !self.should_simplify(source_info, rvalue) {
                     return;
                 }
 
@@ -144,7 +144,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
         }
     }
 
-    fn combine_cast(&self, _source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
+    fn simplify_cast(&self, _source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
         if let Rvalue::Cast(kind, operand, cast_ty) = rvalue {
             let operand_ty = operand.ty(self.local_decls, self.tcx);
             if operand_ty == *cast_ty {
@@ -196,7 +196,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
         }
     }
 
-    fn combine_primitive_clone(
+    fn simplify_primitive_clone(
         &self,
         terminator: &mut Terminator<'tcx>,
         statements: &mut Vec<Statement<'tcx>>,
@@ -239,7 +239,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
 
         if !self.tcx.consider_optimizing(|| {
             format!(
-                "InstCombine - Call: {:?} SourceInfo: {:?}",
+                "InstSimplify - Call: {:?} SourceInfo: {:?}",
                 (fn_def_id, fn_substs),
                 terminator.source_info
             )
@@ -262,7 +262,7 @@ impl<'tcx> InstCombineContext<'tcx, '_> {
         terminator.kind = TerminatorKind::Goto { target: destination_block };
     }
 
-    fn combine_intrinsic_assert(
+    fn simplify_intrinsic_assert(
         &self,
         terminator: &mut Terminator<'tcx>,
         _statements: &mut Vec<Statement<'tcx>>,
diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs
index 8d9a22ea30d..f25a9f042c4 100644
--- a/compiler/rustc_mir_transform/src/lib.rs
+++ b/compiler/rustc_mir_transform/src/lib.rs
@@ -73,7 +73,7 @@ mod ffi_unwind_calls;
 mod function_item_references;
 mod generator;
 mod inline;
-mod instcombine;
+mod instsimplify;
 mod large_enums;
 mod lower_intrinsics;
 mod lower_slice_len;
@@ -547,7 +547,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
             &match_branches::MatchBranchSimplification,
             // inst combine is after MatchBranchSimplification to clean up Ne(_1, false)
             &multiple_return_terminators::MultipleReturnTerminators,
-            &instcombine::InstCombine,
+            &instsimplify::InstSimplify,
             &separate_const_switch::SeparateConstSwitch,
             &simplify::SimplifyLocals::BeforeConstProp,
             &copy_prop::CopyProp,
diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs
index 7e0cef025f7..1b96df3aed5 100644
--- a/compiler/rustc_mir_transform/src/simplify.rs
+++ b/compiler/rustc_mir_transform/src/simplify.rs
@@ -278,7 +278,7 @@ impl<'a, 'tcx> CfgSimplifier<'a, 'tcx> {
     }
 }
 
-pub fn combine_duplicate_switch_targets(terminator: &mut Terminator<'_>) {
+pub fn simplify_duplicate_switch_targets(terminator: &mut Terminator<'_>) {
     if let TerminatorKind::SwitchInt { targets, .. } = &mut terminator.kind {
         let otherwise = targets.otherwise();
         if targets.iter().any(|t| t.1 == otherwise) {
@@ -310,7 +310,7 @@ pub fn remove_duplicate_unreachable_blocks<'tcx>(tcx: TyCtxt<'tcx>, body: &mut B
                 }
             }
 
-            combine_duplicate_switch_targets(terminator);
+            simplify_duplicate_switch_targets(terminator);
 
             self.super_terminator(terminator, location);
         }
diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs
index 243da98c3c2..5cbd7f98b6b 100644
--- a/compiler/rustc_session/src/options.rs
+++ b/compiler/rustc_session/src/options.rs
@@ -1555,7 +1555,7 @@ options! {
         "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
         (default: no)"),
     mir_enable_passes: Vec<(String, bool)> = (Vec::new(), parse_list_with_polarity, [TRACKED],
-        "use like `-Zmir-enable-passes=+DestProp,-InstCombine`. Forces the specified passes to be \
+        "use like `-Zmir-enable-passes=+DestinationPropagation,-InstSimplify`. Forces the specified passes to be \
         enabled, overriding all other checks. Passes that are not specified are enabled or \
         disabled by other flags as usual."),
     mir_keep_place_mention: bool = (false, parse_bool, [TRACKED],