Skip to content

Fix SIGILL crash on CPUs without AVX-512#6

Open
GavinPalmer1984 wants to merge 1 commit intocomputerex:mainfrom
GavinPalmer1984:fix/issue-4-avx512-sigill
Open

Fix SIGILL crash on CPUs without AVX-512#6
GavinPalmer1984 wants to merge 1 commit intocomputerex:mainfrom
GavinPalmer1984:fix/issue-4-avx512-sigill

Conversation

@GavinPalmer1984
Copy link

@GavinPalmer1984 GavinPalmer1984 commented Mar 19, 2026

Summary

  • #pragma GCC target(...) in quant/simd_dot.c, quant/simd_qq_dot.c, and quant/cpool.c forced AVX-512 instruction generation regardless of the build machine
  • This overrode the -march=native flag already present in CGo CFLAGS, causing GCC's auto-vectorizer to emit EVEX-prefixed AVX-512 instructions
  • Result: SIGILL crash on CPUs without AVX-512 (Intel pre-11th gen, AMD pre-Zen 4)

Fix

Remove the #pragma GCC target(...) directives entirely and rely on -march=native (already in #cgo CFLAGS), which detects CPU capabilities at compile time:

  • AVX-512 machines: GCC auto-vectorizes with AVX-512 as before — no performance regression
  • AVX2-only machines: GCC correctly limits to AVX2/FMA/F16C

The pragmas were originally added to "avoid CGo flag restrictions", but -march=native already handles this correctly.

Test plan

  • Verified SIGILL crash on i7-8700K (AVX2 only) before fix
  • After fix, builds and runs successfully — no illegal instructions
  • Verify no performance regression on AVX-512 hardware (should be identical since -march=native enables the same features)

Fixes #4

🤖 Generated with Claude Code

The #pragma GCC target directives in simd_dot.c, simd_qq_dot.c, and
cpool.c forced AVX-512 instruction generation regardless of the build
machine's capabilities. This overrode the -march=native flag already
present in CGo CFLAGS, causing GCC to auto-vectorize with AVX-512
instructions that crash (SIGILL) on CPUs without AVX-512 support.

Remove the target pragmas entirely and rely on -march=native, which
already detects the CPU at compile time. This means:
- AVX-512 machines: GCC auto-vectorizes with AVX-512 as before
- AVX2-only machines: GCC correctly limits to AVX2/FMA/F16C
- No performance regression on capable hardware

Fixes computerex#4

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@GavinPalmer1984 GavinPalmer1984 force-pushed the fix/issue-4-avx512-sigill branch from 6d64a74 to da97d6a Compare March 19, 2026 13:46
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.

SIGILL crash on CPUs without AVX-512 (e.g. i7-8700K)

1 participant