15 Commits

Author SHA1 Message Date
Haocong Lu
e0cf581ad4
[Clang][X86] Remove useless extractvalue on aesencwide/aesdecwide builtin CodeGen (#175113)
This is a pre-commit of CIR codegen for `aesencwide/aesdecwide` builtin,
remove useless `extractvalue` on clang CodeGen for this builtin.
2026-01-12 11:29:46 +08:00
Gergo Stomfai
8290134a74
[X86] EmitX86BuiltinExpr - attempt to convert SSE41/AVX1 roundps/d/ss/sd builtins to regular rounding modes (#171227)
Adding clauses to `CodeGenFunction::EmitX86BuiltinExpr` to convert
SSE4.1/AVX1 builts `roundps/pd/ss/sd` to regular rounding modes.

We use:
1. `roundeven/floor/ceil/trunc` when not using MXCSR or _MM_FROUND_RAISE_EXC , and FP mode is not strict,
2. `experimental_constrained_roundeven/floor/ceil/trunc` when not using MXCSR or _MM_FROUND_RAISE_EXC , and FP mode is strict
3. `x86_sse41/avx_round_ps/pd/ss/sd` when using MXCSR or _MM_FROUND_RAISE_EXC .

Closes #170273
2025-12-23 13:44:21 +00:00
Simon Pilgrim
fca41f4aa1
[X86] Replace BF16 to F32 conversions with generic conversions (#169781)
Let standard casting / builtin_convertvector handle the conversions from BF16 to F32

My only query is how to best implement _mm_cvtpbh_ps - I went for the
v8bf16 -> v8f32 conversion followed by subvector extraction in the end,
but could just as easily extract a v4bf16 first - makes no difference to
final optimized codegen.

First part of #154911
2025-11-27 13:09:26 +00:00
Nikolas Klauser
0dbedd195c
[Clang] Replace some x86 sqrt builtins with the generic __builtin_elementwise_sqrt versions (#165682) 2025-11-27 11:36:43 +00:00
Simon Pilgrim
59c01cc8bb
[Headers][X86] Update FMA3/FMA4 scalar intrinsics to use __builtin_elementwise_fma and support constexpr (#154731)
Now that #152455 is done, we can make all the scalar fma intrinsics to
wrap __builtin_elementwise_fma, which also allows constexpr

The main difference is that FMA4 intrinsics guarantee that the upper
elements are zero, while FMA3 passes through the destination register
elements like older scalar instructions

Fixes #154555
2025-11-13 11:36:22 +00:00
Mikołaj Piróg
5322fb6268
[X86] Remove AMX-TRANSPOSE (#165556)
Per Intel Architecture Instruction Set Extensions Programming Reference
rev. 59 (https://cdrdv2.intel.com/v1/dl/getContent/671368), Revision
History entry for revision -59, AMX-TRANSPOSE was removed
2025-10-31 12:50:21 +01:00
Simon Pilgrim
5169bb4c81
[clang][x86] Change SLLDQ/SRLDQ byte shift intrinsics to use vXi8 types instead of vXi64 (#158671)
As noted on #156494 and #157403 - its much easier to work with the byte
shift intrinsics if we treat them as vXi8 types instead of vXi64 types
which will require bitcasting

We already do this for the PALIGNR intrinsics which are a more advanced
version of the same shuffle
2025-09-16 07:53:59 +00:00
moorabbit
73cf62b254
[Headers][X86] Use __builtin_elementwise_ctlz instead of avx512cd intrinsics. (#155089)
The following avx512 intrinsics were removed:
- `__builtin_ia32_vplzcntd_128`
- `__builtin_ia32_vplzcntd_256`
- `__builtin_ia32_vplzcntd_512`
- `__builtin_ia32_vplzcntq_128`
- `__builtin_ia32_vplzcntq_256`
- `__builtin_ia32_vplzcntq_512`

Users of the removed intrinsics (e.g. `_mm512_lzcnt_epi64`,
`_mm_lzcnt_epi32`) are now relying on `__builtin_elementwise_ctlz` and
are marked as `constexpr`.

Fixes: #154279
2025-08-28 17:07:47 +00:00
Simon Pilgrim
91fff70740
[clang][X86] Replace vprot/vprol/vpror/vshld/vshrd intrinsics with __builtin_elementwise_fshl/fshr (#153229)
Replaces the XOP/AVX512 per-element rotation/funnel shift builtins with the generic __builtin_elementwise_fshl/fshr

We still have uniform immediate variants to handle next.

Part of #153152
2025-08-13 10:28:30 +01:00
moorabbit
f8653cecd1
[Clang][X86] Replace F16C vcvtph2ps/256 intrinsics with (convert|shuffle)vector builtins (#152911)
The following intrinsics were replaced by a combination of
`__builtin_shufflevector` and `__builtin_convertvector`:
- `__builtin_ia32_vcvtph2ps`
- `__builtin_ia32_vcvtph2ps256`

Fixes #152749
2025-08-12 16:32:19 +01:00
moorabbit
989c0d2526
[Clang][X86] Replace unnecessary vfmadd* builtins with element_wise_fma (#152545)
The following intrinsics were replaced by `__builtin_elementwise_fma`:
- `__builtin_ia32_vfmaddps(256)`
- `__builtin_ia32_vfmaddpd(256)`
- `__builtin_ia32_vfmaddph(256)`
- `__builtin_ia32_vfmaddbf16(128 | 256 | 512)`

All the aforementioned `__builtin_ia32_vfmadd*` intrinsics are
equivalent to a `__builtin_elementwise_fma`, so keeping them is an
unnecessary indirection.

Fixes [#152461](https://github.com/llvm/llvm-project/issues/152461)

---------

Co-authored-by: Simon Pilgrim <llvm-dev@redking.me.uk>
2025-08-08 20:51:15 +01:00
Reid Kleckner
948cc91188
Reapply "[Win/X86] Make _m_prefetch[w] builtins to avoid winnt.h conflicts (#115099)" (#138360)
This reverts commit 83ff9d4a34b1e579dd809759d13b70b8837f0cde.

Don't change the builtin signature of _mm_prefetch this time.
2025-06-24 22:07:07 -06:00
Phoebe Wang
897f9a51b9
[X86][AVX10.2] Replace nepbh with bf16 to match with others, NFCI (#134240) 2025-04-04 11:27:39 +08:00
Jonathan Thackray
a1a74c9e80
[NFC][clang] Remove superfluous header files after refactor in #132252 (#132495)
Remove superfluous header files after refactor in #132252
2025-03-26 14:45:00 +00:00
Jonathan Thackray
7f920e2e5f
[NFC][clang] Split clang/lib/CodeGen/CGBuiltin.cpp into target-specific files (#132252)
clang/lib/CodeGen/CGBuiltin.cpp is over 1MB long (>23k LoC), and can
take minutes to recompile (depending on compiler and host system) when
modified, and 5 seconds for clangd to update for every edit. Splitting
this file was discussed in this thread:

   https://discourse.llvm.org/t/splitting-clang-s-cgbuiltin-cpp-over-23k-lines-long-takes-1min-to-compile/

and the idea has received a number of +1 votes, hence this change.
2025-03-21 19:09:39 +00:00