Use of x86 SIMD intrinsic

ID

c.portability.simd_intrinsics

Severity

low

Remediation Complexity

hard

Remediation Risk

medium

Remediation Effort

high

Resource

Portability

Language

C / C++

Description

Call $F is an x86 SIMD intrinsic, which only compiles on x86/x86-64 targets and ties the code to that architecture. For portable vectorization, prefer a cross-platform SIMD abstraction (e.g. std::experimental::simd / std::simd) or isolate the intrinsic behind an architecture guard.

Rationale

Call $F is an x86 SIMD intrinsic, which only compiles on x86/x86-64 targets and ties the code to that architecture. For portable vectorization, prefer a cross-platform SIMD abstraction (e.g. std::experimental::simd / std::simd) or isolate the intrinsic behind an architecture guard.

The following code illustrates the pattern detected by this rule:

void f(float *x, float *y, float *p, float *q, float *ptr)
{
    // FLAGGED: Use of x86 SIMD intrinsic
    __m128 a = _mm_add_ps(x, y);
    // FLAGGED: Use of x86 SIMD intrinsic
    __m256 b = _mm256_mul_ps(p, q);
    // FLAGGED: Use of x86 SIMD intrinsic
    __m512 c = _mm512_load_ps(ptr);

Remediation

Follow secure coding practices and review the references below for detailed remediation guidance.

Configuration

This detector does not need any configuration.