LLVM does not use ZMM registers for 512-bit vectors on x86_64 macOS
## Summary
On x86_64 macOS, the recent LLVM fails to use ZMM registers for 512-bit vectors even if AVX-512 is enabled via `-mavx512f`.
It leads to a problem when passing 512-bit vectors to C functions via FFI.
## Steps to reproduce
```haskell
-- Main.hs
{-# LANGUAGE MagicHash #-}
{-# LANGUAGE UnboxedTuples #-}
{-# LANGUAGE UnliftedFFITypes #-}
{-# OPTIONS_GHC -fllvm -mavx512f #-}
import GHC.Exts
import GHC.Int
foreign import ccall unsafe "minInt64X8"
minInt64X8# :: Int64X8# -> Int64X8# -> Int64X8#
data Int64X8 = Int64X8# Int64X8#
minInt64X8 :: Int64X8 -> Int64X8 -> Int64X8
minInt64X8 (Int64X8# a) (Int64X8# b) = Int64X8# (minInt64X8# a b)
{-# NOINLINE minInt64X8 #-}
broadcastInt64X8 :: Int64 -> Int64X8
broadcastInt64X8 (I64# x) = Int64X8# (broadcastInt64X8# x)
packInt64X8 :: (Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64) -> Int64X8
packInt64X8 (I64# x0, I64# x1, I64# x2, I64# x3, I64# x4, I64# x5, I64# x6, I64# x7) = Int64X8# (packInt64X8# (# x0, x1, x2, x3, x4, x5, x6, x7 #))
unpackInt64X8 :: Int64X8 -> (Int64, Int64, Int64, Int64, Int64, Int64, Int64, Int64)
unpackInt64X8 (Int64X8# a) = case unpackInt64X8# a of
(# x0, x1, x2, x3, x4, x5, x6, x7 #) -> (I64# x0, I64# x1, I64# x2, I64# x3, I64# x4, I64# x5, I64# x6, I64# x7)
-- You can check the assembly code for this function to see if ZMM registers are used
plusInt64X8 :: Int64X8 -> Int64X8 -> Int64X8
plusInt64X8 (Int64X8# a) (Int64X8# b) = Int64X8# (plusInt64X8# a b)
main :: IO ()
main = do
let a = broadcastInt64X8 3
b = packInt64X8 (1, 2, 3, 4, 5, 6, 7, 8)
c = minInt64X8 a b
print $ unpackInt64X8 c
let d = packInt64X8 (-1, -2, -3, -4, -5, -6, -7, -8)
e = broadcastInt64X8 (-3)
f = minInt64X8 d e
print $ unpackInt64X8 f
print $ unpackInt64X8 (plusInt64X8 a b)
```
```c
// lib.c
#include <x86intrin.h>
__m512i minInt64X8(__m512i a, __m512i b)
{
return _mm512_min_epi64(a, b);
}
```
Using LLVM 18 or newer exhibits the problem:
```
$ ghc -optc -mavx512f -fforce-recomp -pgmlc=llc-mp-18 -pgmlo=opt-mp-18 Main.hs lib.c
$ ./Main
(3,3,3,3,3,3,3,3)
(-5,-6,-7,-8,-5,-6,-7,-8)
(4,5,6,7,8,9,10,11)
```
(`llc-mp-18` and `opt-mp-18` are the programs from LLVM installed with MacPorts)
If you don't have an Intel Mac with AVX-512, you can add `-optlc -mcpu=penryn` to reproduce the problem on Linux:
```
$ uname -s -m
Linux x86_64
$ ghc -optc -mavx512f -fforce-recomp -pgmlc=llc-18 -pgmlo=opt-18 -optlc -mcpu=penryn Main.hs lib.c
$ ./Main
(3,3,3,3,3,3,3,3)
(-5,-6,-7,-8,-5,-6,-7,-8)
(4,5,6,7,8,9,10,11)
```
## Expected behavior
The program runs correctly when using LLVM 17 or older:
```
$ ghc-9.12 -optc -mavx512f -fforce-recomp -pgmlc=llc-mp-17 -pgmlo=opt-mp-17 Main.hs lib.c
$ ./Main
(1,2,3,3,3,3,3,3)
(-3,-3,-3,-4,-5,-6,-7,-8)
(4,5,6,7,8,9,10,11)
```
Or, you can pass `-mcpu=x86-64` or `-mattr=+evex512` to `llc`:
```
$ ghc-9.12 -optc -mavx512f -fforce-recomp -pgmlc=llc-mp-18 -pgmlo=opt-mp-18 -optlc -mcpu=x86-64 Main.hs lib.c
$ ./Main
(1,2,3,3,3,3,3,3)
(-3,-3,-3,-4,-5,-6,-7,-8)
(4,5,6,7,8,9,10,11)
$ ghc-9.12 -optc -mavx512f -fforce-recomp -pgmlc=llc-mp-18 -pgmlo=opt-mp-18 -optlc -mattr=+evex512 Main.hs lib.c
$ ./Main
(1,2,3,3,3,3,3,3)
(-3,-3,-3,-4,-5,-6,-7,-8)
(4,5,6,7,8,9,10,11)
```
## Investigation
Maybe this pull request on LLVM is related: [\[X86\]\[EVEX512\] Restrict attaching EVEX512 for default CPU only, NFCI by phoebewang · Pull Request #65920 · llvm/llvm-project](https://github.com/llvm/llvm-project/pull/65920)
That is, LLVM now requires the `+evex512` attribute to use ZMM registers.
For backward compatibility, LLVM automatically adds it when `+avx512f` is set *and* the CPU is `generic` or `x86-64`.
However, we (GHC) set the CPU to `penryn` on x86_64-apple-darwin, so we don't get this backward-compatible behavior.
I can think of two ways to solve this problem:
* Add the `+evex512` attribute when using LLVM 18 or newer.
* Change the CPU to `x86-64`.
## Environment
* GHC version used: 9.12.2, 9.14.1-alpha1 (9.14.0.20250819), 9.15.20250911 (80a07571623a6fe7692c08dbdee440ff90ce98c2)
* Operating System: macOS
* System Architecture: x86_64
issue