Skip to content

[WebAssembly] Add f16x8.demote_f32x4_zero to wasm_simd128.h.#199795

Open
brendandahl wants to merge 1 commit into
llvm:mainfrom
brendandahl:fp16-demote-header
Open

[WebAssembly] Add f16x8.demote_f32x4_zero to wasm_simd128.h.#199795
brendandahl wants to merge 1 commit into
llvm:mainfrom
brendandahl:fp16-demote-header

Conversation

@brendandahl
Copy link
Copy Markdown
Contributor

Missing header intrinsic.

@brendandahl brendandahl requested a review from dschuff May 26, 2026 23:05
@llvmorg-github-actions llvmorg-github-actions Bot added backend:WebAssembly backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels May 26, 2026
@llvmorg-github-actions
Copy link
Copy Markdown

llvmorg-github-actions Bot commented May 26, 2026

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-backend-webassembly

Author: Brendan Dahl (brendandahl)

Changes

Missing header intrinsic.


Full diff: https://github.com/llvm/llvm-project/pull/199795.diff

2 Files Affected:

  • (modified) clang/lib/Headers/wasm_simd128.h (+7)
  • (modified) cross-project-tests/intrinsic-header-tests/wasm_simd128.c (+7)
diff --git a/clang/lib/Headers/wasm_simd128.h b/clang/lib/Headers/wasm_simd128.h
index 1e6da28c052a0..d44b25559167c 100644
--- a/clang/lib/Headers/wasm_simd128.h
+++ b/clang/lib/Headers/wasm_simd128.h
@@ -2019,6 +2019,13 @@ wasm_f32x4_promote_low_f16x8(v128_t __a) {
       __f32x4);
 }
 
+static __inline__ v128_t __FP16_FN_ATTRS
+wasm_f16x8_demote_f32x4_zero(v128_t __a) {
+  return (v128_t)__builtin_shufflevector(
+      __builtin_convertvector((__f32x4)__a, __f16x4), (__f16x4){0, 0, 0, 0}, 0,
+      1, 2, 3, 4, 5, 6, 7);
+}
+
 static __inline__ v128_t __FP16_FN_ATTRS wasm_f16x8_relaxed_madd(v128_t __a,
                                                                  v128_t __b,
                                                                  v128_t __c) {
diff --git a/cross-project-tests/intrinsic-header-tests/wasm_simd128.c b/cross-project-tests/intrinsic-header-tests/wasm_simd128.c
index b0bea4cb9d60f..f02e5062e3872 100644
--- a/cross-project-tests/intrinsic-header-tests/wasm_simd128.c
+++ b/cross-project-tests/intrinsic-header-tests/wasm_simd128.c
@@ -1039,6 +1039,13 @@ v128_t test_f32x4_promote_low_f16x8(v128_t a) {
   return wasm_f32x4_promote_low_f16x8(a);
 }
 
+// CHECK-LABEL: test_f16x8_demote_f32x4_zero:
+// CHECK: f16x8.demote_f32x4_zero{{$}}
+v128_t test_f16x8_demote_f32x4_zero(v128_t a) {
+  return wasm_f16x8_demote_f32x4_zero(a);
+}
+
+
 // CHECK-LABEL: test_i8x16_shuffle:
 // CHECK: i8x16.shuffle 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
 // 0{{$}}

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 26, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

@brendandahl brendandahl force-pushed the fp16-demote-header branch from 1eed449 to 02de843 Compare May 26, 2026 23:08
@brendandahl brendandahl force-pushed the fp16-demote-header branch from 02de843 to 5da2293 Compare May 26, 2026 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:WebAssembly backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants