Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 618c300

Browse files
committedApr 13, 2024·
Auto merge of #123897 - matthiaskrgr:rollup-v0vvcw2, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #123530 (Enable building tier2 target riscv32im-unknown-none-elf) - #123642 (do not allow using local llvm while using rustc from ci) - #123716 (Update documentation of Path::to_path_buf and Path::ancestors) - #123876 (Update backtrace submodule) - #123888 (Replace a `DefiningOpaqueTypes::No` with `Yes` by asserting that one side of the comparison is a type variable.) - #123890 (removed (mostly) unused code) - #123891 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3a0db6c + f8ef61d commit 618c300

File tree

14 files changed

+129
-227
lines changed

14 files changed

+129
-227
lines changed
 

‎compiler/rustc_hir_analysis/src/check/check.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,6 @@ fn check_static_linkage(tcx: TyCtxt<'_>, def_id: LocalDefId) {
505505
}
506506

507507
pub(crate) fn check_item_type(tcx: TyCtxt<'_>, def_id: LocalDefId) {
508-
let _indenter = indenter();
509508
match tcx.def_kind(def_id) {
510509
DefKind::Static { .. } => {
511510
tcx.ensure().typeck(def_id);

‎compiler/rustc_hir_analysis/src/check/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use rustc_trait_selection::traits::ObligationCtxt;
103103

104104
use crate::errors;
105105
use crate::require_c_abi_if_c_variadic;
106-
use crate::util::common::indenter;
107106

108107
use self::compare_impl_item::collect_return_position_impl_trait_in_trait_tys;
109108
use self::region::region_scope_tree;

‎compiler/rustc_hir_analysis/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ use rustc_middle::middle;
103103
use rustc_middle::mir::interpret::GlobalId;
104104
use rustc_middle::query::Providers;
105105
use rustc_middle::ty::{self, Ty, TyCtxt};
106-
use rustc_middle::util;
107106
use rustc_session::parse::feature_err;
108107
use rustc_span::{symbol::sym, Span};
109108
use rustc_target::spec::abi::Abi;

‎compiler/rustc_hir_typeck/src/fn_ctxt/_impl.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,9 +561,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
561561

562562
// Unify `interior` with `witness` and collect all the resulting obligations.
563563
let span = self.tcx.hir().body(body_id).value.span;
564+
let ty::Infer(ty::InferTy::TyVar(_)) = interior.kind() else {
565+
span_bug!(span, "coroutine interior witness not infer: {:?}", interior.kind())
566+
};
564567
let ok = self
565568
.at(&self.misc(span), self.param_env)
566-
.eq(DefineOpaqueTypes::No, interior, witness)
569+
// Will never define opaque types, as all we do is instantiate a type variable.
570+
.eq(DefineOpaqueTypes::Yes, interior, witness)
567571
.expect("Failed to unify coroutine interior type");
568572
let mut obligations = ok.obligations;
569573

‎compiler/rustc_middle/src/util/common.rs

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
use rustc_data_structures::sync::Lock;
2-
3-
use std::fmt::Debug;
4-
use std::time::{Duration, Instant};
5-
61
#[cfg(test)]
72
mod tests;
83

@@ -26,46 +21,6 @@ pub fn to_readable_str(mut val: usize) -> String {
2621
groups.join("_")
2722
}
2823

29-
pub fn record_time<T, F>(accu: &Lock<Duration>, f: F) -> T
30-
where
31-
F: FnOnce() -> T,
32-
{
33-
let start = Instant::now();
34-
let rv = f();
35-
let duration = start.elapsed();
36-
let mut accu = accu.lock();
37-
*accu += duration;
38-
rv
39-
}
40-
41-
pub fn indent<R, F>(op: F) -> R
42-
where
43-
R: Debug,
44-
F: FnOnce() -> R,
45-
{
46-
// Use in conjunction with the log post-processor like `src/etc/indenter`
47-
// to make debug output more readable.
48-
debug!(">>");
49-
let r = op();
50-
debug!("<< (Result = {:?})", r);
51-
r
52-
}
53-
54-
pub struct Indenter {
55-
_cannot_construct_outside_of_this_module: (),
56-
}
57-
58-
impl Drop for Indenter {
59-
fn drop(&mut self) {
60-
debug!("<<");
61-
}
62-
}
63-
64-
pub fn indenter() -> Indenter {
65-
debug!(">>");
66-
Indenter { _cannot_construct_outside_of_this_module: () }
67-
}
68-
6924
// const wrapper for `if let Some((_, tail)) = name.rsplit_once(':') { tail } else { name }`
7025
pub const fn c_name(name: &'static str) -> &'static str {
7126
// FIXME Simplify the implementation once more `str` methods get const-stable.

‎compiler/rustc_type_ir/src/ty_kind.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,9 @@ pub enum TyKind<I: Interner> {
181181
/// Looking at the following example, the witness for this coroutine
182182
/// may end up as something like `for<'a> [Vec<i32>, &'a Vec<i32>]`:
183183
///
184-
/// ```ignore UNSOLVED (ask @compiler-errors, should this error? can we just swap the yields?)
184+
/// ```
185185
/// #![feature(coroutines)]
186-
/// |a| {
186+
/// static |a| {
187187
/// let x = &vec![3];
188188
/// yield a;
189189
/// yield x[0];

‎config.example.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#
5151
# Note that many of the LLVM options are not currently supported for
5252
# downloading. Currently only the "assertions" option can be toggled.
53-
#download-ci-llvm = if rust.channel == "dev" { "if-unchanged" } else { false }
53+
#download-ci-llvm = if rust.channel == "dev" || rust.download-rustc != false { "if-unchanged" } else { false }
5454

5555
# Indicates whether the LLVM build is a Release or Debug build
5656
#optimize = true

‎library/std/src/path.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,10 +2143,10 @@ impl Path {
21432143
/// # Examples
21442144
///
21452145
/// ```
2146-
/// use std::path::Path;
2146+
/// use std::path::{Path, PathBuf};
21472147
///
21482148
/// let path_buf = Path::new("foo.txt").to_path_buf();
2149-
/// assert_eq!(path_buf, std::path::PathBuf::from("foo.txt"));
2149+
/// assert_eq!(path_buf, PathBuf::from("foo.txt"));
21502150
/// ```
21512151
#[rustc_conversion_suggestion]
21522152
#[must_use = "this returns the result of the operation, \
@@ -2278,10 +2278,9 @@ impl Path {
22782278
/// Produces an iterator over `Path` and its ancestors.
22792279
///
22802280
/// The iterator will yield the `Path` that is returned if the [`parent`] method is used zero
2281-
/// or more times. That means, the iterator will yield `&self`, `&self.parent().unwrap()`,
2282-
/// `&self.parent().unwrap().parent().unwrap()` and so on. If the [`parent`] method returns
2283-
/// [`None`], the iterator will do likewise. The iterator will always yield at least one value,
2284-
/// namely `&self`.
2281+
/// or more times. If the [`parent`] method returns [`None`], the iterator will do likewise.
2282+
/// The iterator will always yield at least one value, namely `Some(&self)`. Next it will yield
2283+
/// `&self.parent()`, `&self.parent().and_then(Path::parent)` and so on.
22852284
///
22862285
/// # Examples
22872286
///

‎src/bootstrap/src/core/config/config.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,9 +2483,20 @@ impl Config {
24832483
llvm::is_ci_llvm_available(self, asserts)
24842484
}
24852485
};
2486+
24862487
match download_ci_llvm {
2487-
None => self.channel == "dev" && if_unchanged(),
2488-
Some(StringOrBool::Bool(b)) => b,
2488+
None => {
2489+
(self.channel == "dev" || self.download_rustc_commit.is_some()) && if_unchanged()
2490+
}
2491+
Some(StringOrBool::Bool(b)) => {
2492+
if !b && self.download_rustc_commit.is_some() {
2493+
panic!(
2494+
"`llvm.download-ci-llvm` cannot be set to `false` if `rust.download-rustc` is set to `true` or `if-unchanged`."
2495+
);
2496+
}
2497+
2498+
b
2499+
}
24892500
// FIXME: "if-available" is deprecated. Remove this block later (around mid 2024)
24902501
// to not break builds between the recent-to-old checkouts.
24912502
Some(StringOrBool::String(s)) if s == "if-available" => {

‎src/ci/docker/host-x86_64/dist-various-1/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ ENV TARGETS=$TARGETS,thumbv8m.base-none-eabi
9999
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabi
100100
ENV TARGETS=$TARGETS,thumbv8m.main-none-eabihf
101101
ENV TARGETS=$TARGETS,riscv32i-unknown-none-elf
102+
ENV TARGETS=$TARGETS,riscv32im-unknown-none-elf
102103
ENV TARGETS=$TARGETS,riscv32imc-unknown-none-elf
103104
ENV TARGETS=$TARGETS,riscv32imac-unknown-none-elf
104105
ENV TARGETS=$TARGETS,riscv32imafc-unknown-none-elf
@@ -130,6 +131,8 @@ ENV CFLAGS_armv5te_unknown_linux_musleabi="-march=armv5te -marm -mfloat-abi=soft
130131
CFLAGS_aarch64_unknown_none=-mstrict-align -march=armv8-a+fp+simd \
131132
CC_riscv32i_unknown_none_elf=riscv32-unknown-elf-gcc \
132133
CFLAGS_riscv32i_unknown_none_elf=-march=rv32i -mabi=ilp32 \
134+
CC_riscv32im_unknown_none_elf=riscv32-unknown-elf-gcc \
135+
CFLAGS_riscv32im_unknown_none_elf=-march=rv32im -mabi=ilp32 \
133136
CC_riscv32imc_unknown_none_elf=riscv32-unknown-elf-gcc \
134137
CFLAGS_riscv32imc_unknown_none_elf=-march=rv32imc -mabi=ilp32 \
135138
CC_riscv32imac_unknown_none_elf=riscv32-unknown-elf-gcc \

‎src/tools/miri/cargo-miri/src/phases.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,10 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
454454
continue;
455455
}
456456
// If the REPLACE_LIBRS hack is enabled and we are building a `lib.rs` file, and a
457-
// `lib.miri.rs` file exists, then build that instead. We only consider relative paths
458-
// as cargo uses those for files in the workspace; dependencies from crates.io get
459-
// absolute paths.
457+
// `lib.miri.rs` file exists, then build that instead.
460458
if replace_librs {
461459
let path = Path::new(&arg);
462-
if path.is_relative()
463-
&& path.file_name().is_some_and(|f| f == "lib.rs")
464-
&& path.is_file()
465-
{
460+
if path.file_name().is_some_and(|f| f == "lib.rs") && path.is_file() {
466461
let miri_rs = Path::new(&arg).with_extension("miri.rs");
467462
if miri_rs.is_file() {
468463
if verbose > 0 {

‎src/tools/miri/src/shims/x86/mod.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,86 @@ fn unary_op_ps<'tcx>(
468468
Ok(())
469469
}
470470

471+
enum ShiftOp {
472+
/// Shift left, logically (shift in zeros) -- same as shift left, arithmetically
473+
Left,
474+
/// Shift right, logically (shift in zeros)
475+
RightLogic,
476+
/// Shift right, arithmetically (shift in sign)
477+
RightArith,
478+
}
479+
480+
/// Shifts each element of `left` by a scalar amount. The shift amount
481+
/// is determined by the lowest 64 bits of `right` (which is a 128-bit vector).
482+
///
483+
/// For logic shifts, when right is larger than BITS - 1, zero is produced.
484+
/// For arithmetic right-shifts, when right is larger than BITS - 1, the sign
485+
/// bit is copied to remaining bits.
486+
fn shift_simd_by_scalar<'tcx>(
487+
this: &mut crate::MiriInterpCx<'_, 'tcx>,
488+
left: &OpTy<'tcx, Provenance>,
489+
right: &OpTy<'tcx, Provenance>,
490+
which: ShiftOp,
491+
dest: &MPlaceTy<'tcx, Provenance>,
492+
) -> InterpResult<'tcx, ()> {
493+
let (left, left_len) = this.operand_to_simd(left)?;
494+
let (dest, dest_len) = this.mplace_to_simd(dest)?;
495+
496+
assert_eq!(dest_len, left_len);
497+
// `right` may have a different length, and we only care about its
498+
// lowest 64bit anyway.
499+
500+
// Get the 64-bit shift operand and convert it to the type expected
501+
// by checked_{shl,shr} (u32).
502+
// It is ok to saturate the value to u32::MAX because any value
503+
// above BITS - 1 will produce the same result.
504+
let shift = u32::try_from(extract_first_u64(this, right)?).unwrap_or(u32::MAX);
505+
506+
for i in 0..dest_len {
507+
let left = this.read_scalar(&this.project_index(&left, i)?)?;
508+
let dest = this.project_index(&dest, i)?;
509+
510+
let res = match which {
511+
ShiftOp::Left => {
512+
let left = left.to_uint(dest.layout.size)?;
513+
let res = left.checked_shl(shift).unwrap_or(0);
514+
// `truncate` is needed as left-shift can make the absolute value larger.
515+
Scalar::from_uint(dest.layout.size.truncate(res), dest.layout.size)
516+
}
517+
ShiftOp::RightLogic => {
518+
let left = left.to_uint(dest.layout.size)?;
519+
let res = left.checked_shr(shift).unwrap_or(0);
520+
// No `truncate` needed as right-shift can only make the absolute value smaller.
521+
Scalar::from_uint(res, dest.layout.size)
522+
}
523+
ShiftOp::RightArith => {
524+
let left = left.to_int(dest.layout.size)?;
525+
// On overflow, copy the sign bit to the remaining bits
526+
let res = left.checked_shr(shift).unwrap_or(left >> 127);
527+
// No `truncate` needed as right-shift can only make the absolute value smaller.
528+
Scalar::from_int(res, dest.layout.size)
529+
}
530+
};
531+
this.write_scalar(res, &dest)?;
532+
}
533+
534+
Ok(())
535+
}
536+
537+
/// Takes a 128-bit vector, transmutes it to `[u64; 2]` and extracts
538+
/// the first value.
539+
fn extract_first_u64<'tcx>(
540+
this: &crate::MiriInterpCx<'_, 'tcx>,
541+
op: &OpTy<'tcx, Provenance>,
542+
) -> InterpResult<'tcx, u64> {
543+
// Transmute vector to `[u64; 2]`
544+
let array_layout = this.layout_of(Ty::new_array(this.tcx.tcx, this.tcx.types.u64, 2))?;
545+
let op = op.transmute(array_layout, this)?;
546+
547+
// Get the first u64 from the array
548+
this.read_scalar(&this.project_index(&op, 0)?)?.to_u64()
549+
}
550+
471551
// Rounds the first element of `right` according to `rounding`
472552
// and copies the remaining elements from `left`.
473553
fn round_first<'tcx, F: rustc_apfloat::Float>(

‎src/tools/miri/src/shims/x86/sse2.rs

Lines changed: 17 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use rustc_apfloat::ieee::Double;
2-
use rustc_middle::ty::layout::LayoutOf as _;
3-
use rustc_middle::ty::Ty;
42
use rustc_span::Symbol;
53
use rustc_target::spec::abi::Abi;
64

7-
use super::{bin_op_simd_float_all, bin_op_simd_float_first, convert_float_to_int, FloatBinOp};
5+
use super::{
6+
bin_op_simd_float_all, bin_op_simd_float_first, convert_float_to_int, shift_simd_by_scalar,
7+
FloatBinOp, ShiftOp,
8+
};
89
use crate::*;
910
use shims::foreign_items::EmulateForeignItemResult;
1011

@@ -109,156 +110,27 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
109110
this.write_scalar(Scalar::from_u64(res.into()), &dest)?;
110111
}
111112
}
112-
// Used to implement the _mm_{sll,srl,sra}_epi16 functions.
113-
// Shifts 16-bit packed integers in left by the amount in right.
114-
// Both operands are vectors of 16-bit integers. However, right is
115-
// interpreted as a single 64-bit integer (remaining bits are ignored).
116-
// For logic shifts, when right is larger than 15, zero is produced.
117-
// For arithmetic shifts, when right is larger than 15, the sign bit
113+
// Used to implement the _mm_{sll,srl,sra}_epi{16,32,64} functions
114+
// (except _mm_sra_epi64, which is not available in SSE2).
115+
// Shifts N-bit packed integers in left by the amount in right.
116+
// Both operands are 128-bit vectors. However, right is interpreted as
117+
// a single 64-bit integer (remaining bits are ignored).
118+
// For logic shifts, when right is larger than N - 1, zero is produced.
119+
// For arithmetic shifts, when right is larger than N - 1, the sign bit
118120
// is copied to remaining bits.
119-
"psll.w" | "psrl.w" | "psra.w" => {
121+
"psll.w" | "psrl.w" | "psra.w" | "psll.d" | "psrl.d" | "psra.d" | "psll.q"
122+
| "psrl.q" => {
120123
let [left, right] =
121124
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
122125

123-
let (left, left_len) = this.operand_to_simd(left)?;
124-
let (right, right_len) = this.operand_to_simd(right)?;
125-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
126-
127-
assert_eq!(dest_len, left_len);
128-
assert_eq!(dest_len, right_len);
129-
130-
enum ShiftOp {
131-
Sll,
132-
Srl,
133-
Sra,
134-
}
135126
let which = match unprefixed_name {
136-
"psll.w" => ShiftOp::Sll,
137-
"psrl.w" => ShiftOp::Srl,
138-
"psra.w" => ShiftOp::Sra,
127+
"psll.w" | "psll.d" | "psll.q" => ShiftOp::Left,
128+
"psrl.w" | "psrl.d" | "psrl.q" => ShiftOp::RightLogic,
129+
"psra.w" | "psra.d" => ShiftOp::RightArith,
139130
_ => unreachable!(),
140131
};
141132

142-
// Get the 64-bit shift operand and convert it to the type expected
143-
// by checked_{shl,shr} (u32).
144-
// It is ok to saturate the value to u32::MAX because any value
145-
// above 15 will produce the same result.
146-
let shift = extract_first_u64(this, &right)?.try_into().unwrap_or(u32::MAX);
147-
148-
for i in 0..dest_len {
149-
let left = this.read_scalar(&this.project_index(&left, i)?)?.to_u16()?;
150-
let dest = this.project_index(&dest, i)?;
151-
152-
let res = match which {
153-
ShiftOp::Sll => left.checked_shl(shift).unwrap_or(0),
154-
ShiftOp::Srl => left.checked_shr(shift).unwrap_or(0),
155-
#[allow(clippy::cast_possible_wrap, clippy::cast_sign_loss)]
156-
ShiftOp::Sra => {
157-
// Convert u16 to i16 to use arithmetic shift
158-
let left = left as i16;
159-
// Copy the sign bit to the remaining bits
160-
left.checked_shr(shift).unwrap_or(left >> 15) as u16
161-
}
162-
};
163-
164-
this.write_scalar(Scalar::from_u16(res), &dest)?;
165-
}
166-
}
167-
// Used to implement the _mm_{sll,srl,sra}_epi32 functions.
168-
// 32-bit equivalent to the shift functions above.
169-
"psll.d" | "psrl.d" | "psra.d" => {
170-
let [left, right] =
171-
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
172-
173-
let (left, left_len) = this.operand_to_simd(left)?;
174-
let (right, right_len) = this.operand_to_simd(right)?;
175-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
176-
177-
assert_eq!(dest_len, left_len);
178-
assert_eq!(dest_len, right_len);
179-
180-
enum ShiftOp {
181-
Sll,
182-
Srl,
183-
Sra,
184-
}
185-
let which = match unprefixed_name {
186-
"psll.d" => ShiftOp::Sll,
187-
"psrl.d" => ShiftOp::Srl,
188-
"psra.d" => ShiftOp::Sra,
189-
_ => unreachable!(),
190-
};
191-
192-
// Get the 64-bit shift operand and convert it to the type expected
193-
// by checked_{shl,shr} (u32).
194-
// It is ok to saturate the value to u32::MAX because any value
195-
// above 31 will produce the same result.
196-
let shift = extract_first_u64(this, &right)?.try_into().unwrap_or(u32::MAX);
197-
198-
for i in 0..dest_len {
199-
let left = this.read_scalar(&this.project_index(&left, i)?)?.to_u32()?;
200-
let dest = this.project_index(&dest, i)?;
201-
202-
let res = match which {
203-
ShiftOp::Sll => left.checked_shl(shift).unwrap_or(0),
204-
ShiftOp::Srl => left.checked_shr(shift).unwrap_or(0),
205-
#[allow(clippy::cast_possible_wrap, clippy::cast_sign_loss)]
206-
ShiftOp::Sra => {
207-
// Convert u32 to i32 to use arithmetic shift
208-
let left = left as i32;
209-
// Copy the sign bit to the remaining bits
210-
left.checked_shr(shift).unwrap_or(left >> 31) as u32
211-
}
212-
};
213-
214-
this.write_scalar(Scalar::from_u32(res), &dest)?;
215-
}
216-
}
217-
// Used to implement the _mm_{sll,srl}_epi64 functions.
218-
// 64-bit equivalent to the shift functions above, except _mm_sra_epi64,
219-
// which is not available in SSE2.
220-
"psll.q" | "psrl.q" => {
221-
let [left, right] =
222-
this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
223-
224-
let (left, left_len) = this.operand_to_simd(left)?;
225-
let (right, right_len) = this.operand_to_simd(right)?;
226-
let (dest, dest_len) = this.mplace_to_simd(dest)?;
227-
228-
assert_eq!(dest_len, left_len);
229-
assert_eq!(dest_len, right_len);
230-
231-
enum ShiftOp {
232-
Sll,
233-
Srl,
234-
}
235-
let which = match unprefixed_name {
236-
"psll.q" => ShiftOp::Sll,
237-
"psrl.q" => ShiftOp::Srl,
238-
_ => unreachable!(),
239-
};
240-
241-
// Get the 64-bit shift operand and convert it to the type expected
242-
// by checked_{shl,shr} (u32).
243-
// It is ok to saturate the value to u32::MAX because any value
244-
// above 63 will produce the same result.
245-
let shift = this
246-
.read_scalar(&this.project_index(&right, 0)?)?
247-
.to_u64()?
248-
.try_into()
249-
.unwrap_or(u32::MAX);
250-
251-
for i in 0..dest_len {
252-
let left = this.read_scalar(&this.project_index(&left, i)?)?.to_u64()?;
253-
let dest = this.project_index(&dest, i)?;
254-
255-
let res = match which {
256-
ShiftOp::Sll => left.checked_shl(shift).unwrap_or(0),
257-
ShiftOp::Srl => left.checked_shr(shift).unwrap_or(0),
258-
};
259-
260-
this.write_scalar(Scalar::from_u64(res), &dest)?;
261-
}
133+
shift_simd_by_scalar(this, left, right, which, dest)?;
262134
}
263135
// Used to implement the _mm_cvtps_epi32, _mm_cvttps_epi32, _mm_cvtpd_epi32
264136
// and _mm_cvttpd_epi32 functions.
@@ -585,17 +457,3 @@ pub(super) trait EvalContextExt<'mir, 'tcx: 'mir>:
585457
Ok(EmulateForeignItemResult::NeedsJumping)
586458
}
587459
}
588-
589-
/// Takes a 128-bit vector, transmutes it to `[u64; 2]` and extracts
590-
/// the first value.
591-
fn extract_first_u64<'tcx>(
592-
this: &crate::MiriInterpCx<'_, 'tcx>,
593-
op: &MPlaceTy<'tcx, Provenance>,
594-
) -> InterpResult<'tcx, u64> {
595-
// Transmute vector to `[u64; 2]`
596-
let u64_array_layout = this.layout_of(Ty::new_array(this.tcx.tcx, this.tcx.types.u64, 2))?;
597-
let op = op.transmute(u64_array_layout, this)?;
598-
599-
// Get the first u64 from the array
600-
this.read_scalar(&this.project_index(&op, 0)?)?.to_u64()
601-
}

0 commit comments

Comments
 (0)
Please sign in to comment.