about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2022-01-09 17:11:28 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2022-01-09 17:11:28 +0100
commit300974714c96524806b44e36c5d6a7d0e854fc3e (patch)
tree5100a29ff76192753665571824444961907874a4
parenta1a164083ea9cdf8f3d6f053cdfb6b3355787c44 (diff)
downloadrust-300974714c96524806b44e36c5d6a7d0e854fc3e.tar.gz
rust-300974714c96524806b44e36c5d6a7d0e854fc3e.zip
Dedup write_cvalue calls in codegen_float_intrinsic_call
Also directly use an array instead of going through a tuple. This
reduces the amount of llvm ir lines for this function by almost half
from 3086 to 1662.
-rw-r--r--src/intrinsics/mod.rs32
1 files changed, 22 insertions, 10 deletions
diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs
index 27e3b1b11f1..0d667847b9a 100644
--- a/src/intrinsics/mod.rs
+++ b/src/intrinsics/mod.rs
@@ -393,7 +393,16 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
         let ret_block = fx.get_block(destination.expect("Float intrinsics don't diverge").1);
         fx.bcx.ins().jump(ret_block, &[]);
     } else {
-        codegen_regular_intrinsic_call(fx, instance, intrinsic, substs, args, ret, span, destination);
+        codegen_regular_intrinsic_call(
+            fx,
+            instance,
+            intrinsic,
+            substs,
+            args,
+            ret,
+            span,
+            destination,
+        );
     }
 }
 
@@ -407,24 +416,27 @@ fn codegen_float_intrinsic_call<'tcx>(
         ($fx:expr, $intrinsic:expr, $ret:expr, $args:expr, $(
             $name:ident($($arg:ident),*) -> $ty:ident => $func:ident,
         )*) => {
-            match $intrinsic {
+            let res = match $intrinsic {
                 $(
                     sym::$name => {
                         if let [$(ref $arg),*] = *$args {
-                            let ($($arg,)*) = (
-                                $(codegen_operand($fx, $arg),)*
-                            );
-                            let res = $fx.easy_call(stringify!($func), &[$($arg),*], $fx.tcx.types.$ty);
-                            $ret.write_cvalue($fx, res);
-
-                            return true;
+                            let args = [$(codegen_operand($fx, $arg),)*];
+                            Some($fx.easy_call(stringify!($func), &args, $fx.tcx.types.$ty))
+                        } else {
+                            None
                         }
                     }
                 )*
                 _ => return false,
+            };
+
+            if let Some(res) = res {
+                $ret.write_cvalue($fx, res);
+            } else {
+                bug!("wrong number of args for intrinsic {:?}", $intrinsic);
             }
 
-            bug!("wrong number of args for intrinsic {:?}", $intrinsic);
+            true
         }
     }