Skip to content

Unit tests are constant-folded #86

Closed
@nominolo

Description

@nominolo

I noticed that some of our unit tests get constant folded which probably defeats their purpose. For example, when compiled with cargo +nightly test --release the test

    #[simd_test = "sse"]
    unsafe fn _mm_mul_ps() {
        let a = f32x4::new(-1.0, 5.0, 0.0, -10.0);
        let b = f32x4::new(-100.0, 20.0, 0.0, -5.0);
        let r = sse::_mm_mul_ps(a, b);
        assert_eq!(r, f32x4::new(100.0, 100.0, 0.0, 50.0));
    }

compiles to:

otool -tv target/release/deps/stdsimd-c75022df61552be7 | grep --color -A50 _mm_mul_ps
...
__ZN7stdsimd3x863sse5tests10_mm_mul_ps17h039fc36f66a51b81E:
0000000100003ea0	pushq	%rbp
0000000100003ea1	movq	%rsp, %rbp
0000000100003ea4	popq	%rbp
0000000100003ea5	retq

That looks like a no-op to me, so I suspect that this test is constant-folded by the compiler.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions