Skip to content

Commit ad26c1f

Browse files
committed
Auto merge of #149941 - jhpratt:rollup-9p1xc2t, r=jhpratt
Rollup of 10 pull requests Successful merges: - rust-lang/rust#145278 (Update `rustc_codegen_gcc` rotate operation document) - rust-lang/rust#148837 (Use `let...else` instead of `match foo { ... _ => return };` and `if let ... else return`) - rust-lang/rust#149177 (Add proper suggestion for associated function with unknown field) - rust-lang/rust#149843 (Inherit attributes in delegation) - rust-lang/rust#149860 (Fix: Prevent macro-expanded extern crates from shadowing extern arguments) - rust-lang/rust#149874 (Weak for Arc pointer is marked as DynSend/DynSync) - rust-lang/rust#149903 (Remove unused code in `cfg_old`) - rust-lang/rust#149911 (bootstrap: Don't pass an unused `--color` to compiletest) - rust-lang/rust#149916 (Add a sanity check in case of any duplicate nodes) - rust-lang/rust#149924 (`declare_lint_pass` for `INLINE_ALWAYS_MISMATCHING_TARGET_FEATURES`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 0bf6eee + 0d19b51 commit ad26c1f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/intrinsic/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,9 +460,10 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
460460
}
461461
sym::bitreverse => self.bit_reverse(width, args[0].immediate()),
462462
sym::rotate_left | sym::rotate_right => {
463-
// TODO(antoyo): implement using algorithm from:
463+
// Using optimized branchless algorithm from:
464464
// https://blog.regehr.org/archives/1063
465-
// for other platforms.
465+
// This implementation uses the pattern (x<<n) | (x>>(-n&(width-1)))
466+
// which generates efficient code for other platforms.
466467
let is_left = name == sym::rotate_left;
467468
let val = args[0].immediate();
468469
let raw_shift = args[1].immediate();

src/intrinsic/simd.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -774,24 +774,23 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
774774
return Err(());
775775
}};
776776
}
777-
let (elem_ty_str, elem_ty, cast_type) = if let ty::Float(ref f) = *in_elem.kind() {
778-
let elem_ty = bx.cx.type_float_from_ty(*f);
779-
match f.bit_width() {
780-
16 => ("", elem_ty, Some(bx.cx.double_type)),
781-
32 => ("f", elem_ty, None),
782-
64 => ("", elem_ty, None),
783-
_ => {
784-
return_error!(InvalidMonomorphization::FloatingPointVector {
785-
span,
786-
name,
787-
f_ty: *f,
788-
in_ty
789-
});
790-
}
791-
}
792-
} else {
777+
let ty::Float(ref f) = *in_elem.kind() else {
793778
return_error!(InvalidMonomorphization::FloatingPointType { span, name, in_ty });
794779
};
780+
let elem_ty = bx.cx.type_float_from_ty(*f);
781+
let (elem_ty_str, elem_ty, cast_type) = match f.bit_width() {
782+
16 => ("", elem_ty, Some(bx.cx.double_type)),
783+
32 => ("f", elem_ty, None),
784+
64 => ("", elem_ty, None),
785+
_ => {
786+
return_error!(InvalidMonomorphization::FloatingPointVector {
787+
span,
788+
name,
789+
f_ty: *f,
790+
in_ty
791+
});
792+
}
793+
};
795794

796795
let vec_ty = bx.cx.type_vector(elem_ty, in_len);
797796

0 commit comments

Comments
 (0)