Skip to content

Commit 5efd778

Browse files
committed
Don't generate unnecessary let $arg=$arg for intrinsics
1 parent 246998f commit 5efd778

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/intrinsics/llvm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ pub(crate) fn codegen_llvm_intrinsic_call<'tcx>(
5252
ret.write_cvalue(fx, res);
5353
};
5454
"llvm.x86.sse2.cmp.ps" | "llvm.x86.sse2.cmp.pd", (c x, c y, o kind) {
55-
let kind_const = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const");
56-
let flt_cc = match kind_const.try_to_bits(Size::from_bytes(1)).unwrap_or_else(|| panic!("kind not scalar: {:?}", kind_const)) {
55+
let kind = crate::constant::mir_operand_get_const_val(fx, kind).expect("llvm.x86.sse2.cmp.* kind not const");
56+
let flt_cc = match kind.try_to_bits(Size::from_bytes(1)).unwrap_or_else(|| panic!("kind not scalar: {:?}", kind)) {
5757
0 => FloatCC::Equal,
5858
1 => FloatCC::LessThan,
5959
2 => FloatCC::LessThanOrEqual,

src/intrinsics/mod.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,12 @@ macro intrinsic_pat {
3131
}
3232

3333
macro intrinsic_arg {
34-
(o $fx:expr, $arg:ident) => {
35-
$arg
36-
},
34+
(o $fx:expr, $arg:ident) => {},
3735
(c $fx:expr, $arg:ident) => {
38-
codegen_operand($fx, $arg)
36+
let $arg = codegen_operand($fx, $arg);
3937
},
4038
(v $fx:expr, $arg:ident) => {
41-
codegen_operand($fx, $arg).load_scalar($fx)
39+
let $arg = codegen_operand($fx, $arg).load_scalar($fx);
4240
}
4341
}
4442

@@ -52,9 +50,7 @@ macro intrinsic_match {
5250
$(
5351
$(intrinsic_pat!($($name).*))|* $(if $cond)? => {
5452
if let [$($arg),*] = $args {
55-
let ($($arg,)*) = (
56-
$(intrinsic_arg!($a $fx, $arg),)*
57-
);
53+
$(intrinsic_arg!($a $fx, $arg);)*
5854
$content
5955
} else {
6056
bug!("wrong number of args for intrinsic {:?}", $intrinsic);

0 commit comments

Comments
 (0)