Skip to content

Commit 431766a

Browse files
kazcwalexcrichton
authored andcommitted
fix _mm_castsi128_pd and _mm_castpd_si128 impls (#581)
* fix _mm_castsi128_pd and _mm_castpd_si128 impls The _mm_castX_Y SSE intrinsics are "reinterpreting" casts; LLVM's simd_cast is a "converting" cast. Replace simd_cast with mem::transmute. Fixes #55249 * Temporarily pin CI * Fix i686 segfaults * Fix wasm CI Output of `wasm2wat` has changed! * Fix AppVeyor with an older nightly
1 parent 3076505 commit 431766a

File tree

7 files changed

+17
-5
lines changed

7 files changed

+17
-5
lines changed

.appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ environment:
1010
install:
1111
# Install rust, x86_64-pc-windows-msvc host
1212
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
13-
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly
13+
- rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly-2018-10-20
1414
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
1515
- if NOT "%TARGET%" == "x86_64-pc-windows-msvc" rustup target add %TARGET%
1616
- rustc -vV

.travis.yml

+6
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,13 @@ matrix:
66
fast_finish: true
77
include:
88
- env: TARGET=i586-unknown-linux-gnu
9+
rust: nightly-2018-10-20
910
- env: TARGET=i686-unknown-linux-gnu
11+
rust: nightly-2018-10-20
1012
- env: TARGET=x86_64-unknown-linux-gnu NO_ADD=1
13+
rust: nightly-2018-10-20
1114
- env: TARGET=x86_64-unknown-linux-gnu-emulated NO_ADD=1 STDSIMD_TEST_EVERYTHING=1
15+
rust: nightly-2018-10-20
1216
- env: TARGET=x86_64-linux-android
1317
- env: TARGET=arm-unknown-linux-gnueabihf
1418
- env: TARGET=arm-linux-androideabi
@@ -26,9 +30,11 @@ matrix:
2630
- os: osx
2731
env: TARGET=i686-apple-darwin
2832
script: ci/run.sh
33+
rust: nightly-2018-10-20
2934
- os: osx
3035
env: TARGET=x86_64-apple-darwin NO_ADD=1
3136
script: ci/run.sh
37+
rust: nightly-2018-10-20
3238
- env: TARGET=wasm32-unknown-unknown
3339
- env: TARGET=thumbv6m-none-eabi NOSTD=1
3440
- env: TARGET=thumbv7m-none-eabi NOSTD=1

ci/run.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,11 @@ case ${TARGET} in
3333
# instruction assertion checks to pass below the 20 instruction limit. If
3434
# this is the default, dynamic, then too many instructions are generated
3535
# when we assert the instruction for a function and it causes tests to fail.
36+
#
37+
# It's not clear why `-Z plt=yes` is required here. Probably a bug in LLVM.
38+
# If you can remove it and CI passes, please feel free to do so!
3639
i686-* | i586-*)
37-
export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static"
40+
export RUSTFLAGS="${RUSTFLAGS} -C relocation-model=static -Z plt=yes"
3841
;;
3942
*android*)
4043
export STDSIMD_DISABLE_ASSERT_INSTR=1

coresimd/x86/sse2.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2787,7 +2787,7 @@ pub unsafe fn _mm_castpd_ps(a: __m128d) -> __m128 {
27872787
#[target_feature(enable = "sse2")]
27882788
#[stable(feature = "simd_x86", since = "1.27.0")]
27892789
pub unsafe fn _mm_castpd_si128(a: __m128d) -> __m128i {
2790-
mem::transmute::<i64x2, _>(simd_cast(a))
2790+
mem::transmute(a)
27912791
}
27922792

27932793
/// Casts a 128-bit floating-point vector of `[4 x float]` into a 128-bit
@@ -2820,7 +2820,7 @@ pub unsafe fn _mm_castps_si128(a: __m128) -> __m128i {
28202820
#[target_feature(enable = "sse2")]
28212821
#[stable(feature = "simd_x86", since = "1.27.0")]
28222822
pub unsafe fn _mm_castsi128_pd(a: __m128i) -> __m128d {
2823-
simd_cast(a.as_i64x2())
2823+
mem::transmute(a)
28242824
}
28252825

28262826
/// Casts a 128-bit integer vector into a 128-bit floating-point vector

crates/stdsimd-test/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ cfg-if = "0.1"
1414

1515
[target.wasm32-unknown-unknown.dependencies]
1616
wasm-bindgen = "=0.2.19"
17+
console_error_panic_hook = "0.1"
1718

1819
[features]
1920
default = []

crates/stdsimd-test/src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ use std::{collections::HashMap, env, str};
2626
cfg_if! {
2727
if #[cfg(target_arch = "wasm32")] {
2828
extern crate wasm_bindgen;
29+
extern crate console_error_panic_hook;
2930
pub mod wasm;
3031
use wasm::disassemble_myself;
3132
} else {

crates/stdsimd-test/src/wasm.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ macro_rules! println {
3333

3434
pub(crate) fn disassemble_myself() -> HashMap<String, Vec<Function>> {
3535
use std::path::Path;
36+
::console_error_panic_hook::set_once();
3637
// Our wasm module in the wasm-bindgen test harness is called
3738
// "wasm-bindgen-test_bg". When running in node this is actually a shim JS
3839
// file. Ask node where that JS file is, and then we use that with a wasm
@@ -51,7 +52,7 @@ pub(crate) fn disassemble_myself() -> HashMap<String, Vec<Function>> {
5152
// If we found the table of function pointers, fill in the known
5253
// address for all our `Function` instances
5354
if line.starts_with("(elem") {
54-
for (i, name) in line.split_whitespace().skip(3).enumerate() {
55+
for (i, name) in line.split_whitespace().skip(4).enumerate() {
5556
let name = name.trim_right_matches(")");
5657
for f in ret.get_mut(name).expect("ret.get_mut(name) failed") {
5758
f.addr = Some(i + 1);

0 commit comments

Comments
 (0)