Skip to content

Tests fail when built with native target #50

Open
@AdamNiederer

Description

@AdamNiederer

To reproduce:

RUSTFLAGS="-C target-cpu=native" cargo test --target x86_64-unknown-linux-gnu --release

I believe LLVM is attempting to use avx equivalents of the SSE instructions in a lowering pass. Running tests in this way produces the following output:

failures:

---- x86::sse2::assert_instr__mm_adds_epi16 stdout ----
	disassembly for stdsimd::x86::sse2::_mm_adds_epi16: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vpaddsw %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse2::assert_instr__mm_adds_epi16' panicked at 'failed to find instruction `paddsw` in the disassembly', stdsimd-test/src/lib.rs:292:8
note: Run with `RUST_BACKTRACE=1` for a backtrace.

---- x86::sse41::assert_instr__mm_blendv_epi8 stdout ----
	disassembly for stdsimd::x86::sse41::_mm_blendv_epi8: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vpblendvb %xmm2,%xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopl 0x0(%rax) 
thread 'x86::sse41::assert_instr__mm_blendv_epi8' panicked at 'failed to find instruction `pblendvb` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_add_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_add_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vaddps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_add_ps' panicked at 'failed to find instruction `addps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_add_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_add_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vaddss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_add_ss' panicked at 'failed to find instruction `addss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_div_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_div_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vdivps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_div_ps' panicked at 'failed to find instruction `divps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_max_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_max_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vmaxps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_max_ps' panicked at 'failed to find instruction `maxps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_div_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_div_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vdivss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_div_ss' panicked at 'failed to find instruction `divss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_min_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_min_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vminss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_min_ss' panicked at 'failed to find instruction `minss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_max_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_max_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vmaxss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_max_ss' panicked at 'failed to find instruction `maxss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_movehl_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_movehl_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vunpckhpd %xmm0,%xmm1,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_movehl_ps' panicked at 'failed to find instruction `movhlps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_min_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_min_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vminps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_min_ps' panicked at 'failed to find instruction `minps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_movelh_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_movelh_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vunpcklpd %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_movelh_ps' panicked at 'failed to find instruction `unpcklpd` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_mul_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_mul_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vmulss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_mul_ss' panicked at 'failed to find instruction `mulss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_movemask_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_movemask_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vmovmskps %xmm0,%eax 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_movemask_ps' panicked at 'failed to find instruction `movmskps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_mul_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_mul_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vmulps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_mul_ps' panicked at 'failed to find instruction `mulps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_rcp_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_rcp_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vrcpss %xmm0,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_rcp_ss' panicked at 'failed to find instruction `rcpss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_rcp_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_rcp_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vrcpps %xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_rcp_ps' panicked at 'failed to find instruction `rcpps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_rsqrt_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_rsqrt_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vrsqrtps %xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_rsqrt_ps' panicked at 'failed to find instruction `rsqrtps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_rsqrt_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_rsqrt_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vrsqrtss %xmm0,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_rsqrt_ss' panicked at 'failed to find instruction `rsqrtss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_sqrt_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_sqrt_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vsqrtss %xmm0,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_sqrt_ss' panicked at 'failed to find instruction `sqrtss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_sub_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_sub_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vsubps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_sub_ps' panicked at 'failed to find instruction `subps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_sub_ss stdout ----
	disassembly for stdsimd::x86::sse::_mm_sub_ss: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vsubss %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_sub_ss' panicked at 'failed to find instruction `subss` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_unpacklo_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_unpacklo_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vunpcklps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_unpacklo_ps' panicked at 'failed to find instruction `unpcklps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__test_mm_shuffle_ps stdout ----
	disassembly for stdsimd::x86::sse::_test_mm_shuffle_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vshufps $0x3,%xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopl 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__test_mm_shuffle_ps' panicked at 'failed to find instruction `shufps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_sqrt_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_sqrt_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vsqrtps %xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_sqrt_ps' panicked at 'failed to find instruction `sqrtps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::sse::assert_instr__mm_unpackhi_ps stdout ----
	disassembly for stdsimd::x86::sse::_mm_unpackhi_ps: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vunpckhps %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopw 0x0(%rax,%rax,1) 
thread 'x86::sse::assert_instr__mm_unpackhi_ps' panicked at 'failed to find instruction `unpckhps` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::ssse3::assert_instr__mm_shuffle_epi8 stdout ----
	disassembly for stdsimd::x86::ssse3::_mm_shuffle_epi8: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vpshufb %xmm1,%xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopl 0x0(%rax,%rax,1) 
thread 'x86::ssse3::assert_instr__mm_shuffle_epi8' panicked at 'failed to find instruction `pshufb` in the disassembly', stdsimd-test/src/lib.rs:292:8

---- x86::ssse3::assert_instr__mm_abs_epi8 stdout ----
	disassembly for stdsimd::x86::ssse3::_mm_abs_epi8: 
	 0: push %rbp 
	 1: mov %rsp,%rbp 
	 2: vpabsb %xmm0,%xmm0 
	 3: pop %rbp 
	 4: retq 
	 5: nopl 0x0(%rax,%rax,1) 
thread 'x86::ssse3::assert_instr__mm_abs_epi8' panicked at 'failed to find instruction `pabsb` in the disassembly', stdsimd-test/src/lib.rs:292:8


failures:
    x86::sse2::assert_instr__mm_adds_epi16
    x86::sse41::assert_instr__mm_blendv_epi8
    x86::sse::assert_instr__mm_add_ps
    x86::sse::assert_instr__mm_add_ss
    x86::sse::assert_instr__mm_div_ps
    x86::sse::assert_instr__mm_div_ss
    x86::sse::assert_instr__mm_max_ps
    x86::sse::assert_instr__mm_max_ss
    x86::sse::assert_instr__mm_min_ps
    x86::sse::assert_instr__mm_min_ss
    x86::sse::assert_instr__mm_movehl_ps
    x86::sse::assert_instr__mm_movelh_ps
    x86::sse::assert_instr__mm_movemask_ps
    x86::sse::assert_instr__mm_mul_ps
    x86::sse::assert_instr__mm_mul_ss
    x86::sse::assert_instr__mm_rcp_ps
    x86::sse::assert_instr__mm_rcp_ss
    x86::sse::assert_instr__mm_rsqrt_ps
    x86::sse::assert_instr__mm_rsqrt_ss
    x86::sse::assert_instr__mm_sqrt_ps
    x86::sse::assert_instr__mm_sqrt_ss
    x86::sse::assert_instr__mm_sub_ps
    x86::sse::assert_instr__mm_sub_ss
    x86::sse::assert_instr__mm_unpackhi_ps
    x86::sse::assert_instr__mm_unpacklo_ps
    x86::sse::assert_instr__test_mm_shuffle_ps
    x86::ssse3::assert_instr__mm_abs_epi8
    x86::ssse3::assert_instr__mm_shuffle_epi8
test result: FAILED. 504 passed; 28 failed; 0 ignored; 0 measured; 0 filtered out

cpuinfo dump:

processor	: 3
vendor_id	: GenuineIntel
cpu family	: 6
model		: 58
model name	: Intel(R) Core(TM) i5-3570K CPU @ 3.40GHz
stepping	: 9
microcode	: 0x1c
cpu MHz		: 2883.276
cache size	: 6144 KB
physical id	: 0
siblings	: 4
core id		: 3
cpu cores	: 4
apicid		: 6
initial apicid	: 6
fpu		: yes
fpu_exception	: yes
cpuid level	: 13
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm cpuid_fault epb tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts
bugs		:
bogomips	: 6804.87
clflush size	: 64
cache_alignment	: 64
address sizes	: 36 bits physical, 48 bits virtual
power management:

There are a few cases in which LLVM further optimizing or widening these instructions would have unwanted effects - hardware validation being the first one which comes to mind. My CPU doesn't support any wider versions of AVX, but I have a hunch that it LLVM would replace the avx instrs with avx512 ones if it could (could anybody with a skl xeon confirm?)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions