Skip to content

Fix POWER7 build: correct AltiVec version guards for POWER8-only intrinsics - #1414

Draft
fo40225 wants to merge 4 commits into
simd-everywhere:masterfrom
fo40225:fix_ppc
Draft

Fix POWER7 build: correct AltiVec version guards for POWER8-only intrinsics#1414
fo40225 wants to merge 4 commits into
simd-everywhere:masterfrom
fo40225:fix_ppc

Conversation

@fo40225

@fo40225 fo40225 commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fix SIMDE_POWER_ALTIVEC_P7_NATIVE guards that protect 64-bit integer AltiVec/VSX operations across four files (sse2.h, sse4.1.h, neon/paddl.h, wasm/simd128.h).
    All affected operations require POWER8 and fail to compile or trigger a GCC 14 ICE when targeting POWER7.
  • Add a power7 (GCC 14, -mcpu=power7) cross-compilation job to the gcc-qemu CI matrix to prevent future regressions.

Background

POWER7 introduced AltiVec (VMX) with 8/16/32-bit integer SIMD, but 64-bit integer vector operations (vaddudm, vsrad, vmulesw, vcmpequd, etc.) were added in POWER8 as part of VSX.

SIMDe's SIMDE_POWER_ALTIVEC_P7_NATIVE macro maps to POWER7 AltiVec availability, so code behind this guard must not use 64-bit integer vector builtins.

Files Changed

File Guards Fixed Operations
simde/x86/sse2.h P7 → P8 vec_add/vec_cmpeq/vec_cmpgt/vec_sl/vec_sr/vec_sra on int64
simde/x86/sse4.1.h P7 → P8 vec_cmpeq on int64
simde/arm/neon/paddl.h P7 → P8 (×2) vec_add/vec_mule/vec_mulo on int64
simde/wasm/simd128.h P7 → P8 (×5) vec_all_ne/vec_sra/vec_mule on int64
.github/workflows/ci.yml New power7 matrix entry

@mr-c mr-c left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @fo40225 ; can you suggest any changes to our CI to confirm this fix and prevent a regression?

@fo40225
fo40225 marked this pull request as draft July 19, 2026 02:47
@mr-c
mr-c marked this pull request as ready for review July 29, 2026 10:02
@mr-c
mr-c enabled auto-merge (rebase) July 29, 2026 10:03
@mr-c
mr-c disabled auto-merge July 29, 2026 14:53
@mr-c
mr-c force-pushed the fix_ppc branch 2 times, most recently from a9c8477 to 126d62a Compare July 29, 2026 15:11
@mr-c

mr-c commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

FYI @fo40225 ; using gcc-15 + power9 causes a few test errors: https://github.com/simd-everywhere/simde/actions/runs/30464647634/job/90619226190?pr=1414

And simde/wasm/simd128.h:7743 with gcc-14 & 15 cause an ICE https://github.com/simd-everywhere/simde/actions/runs/30464647634/job/90619226198?pr=1414#step:9:2319

@mr-c
mr-c force-pushed the fix_ppc branch 3 times, most recently from f58a540 to 72ba8a5 Compare July 30, 2026 00:10
@mr-c
mr-c marked this pull request as draft July 30, 2026 00:14
fo40225 added 4 commits August 1, 2026 09:55
…4.1)

x86/sse2: require POWER8 for vec_float2 in simde_mm_cvtpd_ps

GCC only provides vec_float2 with -mcpu=power8 or later; building
with -mcpu=power7 fails with:

  error: '__builtin_vsx_float2_v2df' requires the '-mcpu=power8'
  and '-mvsx' options

Raise the guard from SIMDE_POWER_ALTIVEC_P7_NATIVE to
SIMDE_POWER_ALTIVEC_P8_NATIVE so POWER7 falls back to the portable
implementation.

x86/sse4.1: require POWER8 for 64-bit vec_cmpeq in simde_mm_cmpeq_epi64

vec_cmpeq on vector long long maps to vcmpequd, a POWER8 (ISA 2.07)
instruction. GCC rejects it below power8:

  error: '__builtin_altivec_vcmpequd' requires the '-mcpu=power8'
  and '-mvsx' options

The previous SIMDE_POWER_ALTIVEC_P6_NATIVE guard was doubly wrong:
POWER6 does not even have the vector long long type. Raise the guard
to SIMDE_POWER_ALTIVEC_P8_NATIVE.
All existing PowerPC CI configurations target power8 or later, so the
"SIMDE_POWER_ALTIVEC_P7_NATIVE without P8_NATIVE" configuration was
never exercised, allowing POWER8-only intrinsics behind P6/P7 guards
(fixed in the previous commit) to slip through.

Build with -mcpu=power7 -Wextra -Werror so any use of a POWER8-only
intrinsic under a P6/P7 guard fails the build, and run the test suite
under QEMU. The exe_wrapper uses -cpu power9 because Ubuntu's ppc64el
userspace has a POWER8 baseline; power7-targeted code is a subset ISA
and runs fine on the newer CPU model.
simde_vpaddlq_s32() and simde_vpaddlq_u32() in paddl.h use vec_add()
on 64-bit integer vectors via vec_mule()/vec_mulo() with int32
operands. The underlying GCC builtins (vaddudm, vmulesw, vmulosw,
vmuleuw, vmulouw) are POWER8 VSX instructions, not available on
POWER7.

Change the guard from SIMDE_POWER_ALTIVEC_P7_NATIVE to
SIMDE_POWER_ALTIVEC_P8_NATIVE so these paths are only used when
targeting POWER8 or later.
Five functions in wasm/simd128.h use SIMDE_POWER_ALTIVEC_P7_NATIVE to
guard code paths that emit 64-bit integer SIMD operations:

  - simde_wasm_i64x2_all_true(): vec_all_ne on int64 (vcmpequd_p)
  - simde_wasm_i32x4_extend_low_i16x8(): vec_sra on long long (vsrad)
  - simde_wasm_i32x4_extend_high_i16x8(): vec_sra on long long (vsrad)
  - simde_wasm_i64x2_extmul_low_i32x4(): vec_mule producing int64
  - simde_wasm_i64x2_extmul_high_i32x4(): vec_mule producing int64
  - simde_wasm_u64x2_extmul_low_u32x4(): vec_mule producing uint64
  - simde_wasm_u64x2_extmul_high_u32x4(): vec_mule producing uint64

All of these require POWER8. The extmul functions additionally cause a
GCC 14 internal compiler error (ICE at optabs.cc:326) when compiled
with -mcpu=power7, because the compiler attempts to expand a
widen-multiply pattern that has no POWER7 implementation.

Change all guards from P7_NATIVE to P8_NATIVE. For the extmul_low
signed/unsigned variants, also collapse the now-redundant inner
P8/P7 branch (the outer guard already guarantees P8).
@fo40225 fo40225 changed the title x86: fix POWER AltiVec guards that require POWER8 (sse2, sse4.1) Fix POWER7 build: correct AltiVec version guards for POWER8-only intrinsics Aug 1, 2026
@fo40225

fo40225 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

I'm not sure how to adjust the CI for Clang 18 to 21 when treating warnings as errors on CPUs that support AVX10.1-512.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants