-
Notifications
You must be signed in to change notification settings - Fork 14.4k
WebAssembly: Add test for sincos intrinsic #147467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
arsenm
merged 1 commit into
main
from
users/arsenm/webassembly/add-sincos-intrinsic-test
Jul 8, 2025
+393
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,393 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5 | ||
; RUN: llc -mtriple=wasm32-unknown-unknown < %s | FileCheck -check-prefixes=CHECK,WASM32 %s | ||
; RUN: llc -mtriple=wasm64-unknown-unknown < %s | FileCheck -check-prefixes=CHECK,WASM64 %s | ||
|
||
define { half, half } @test_sincos_f16(half %a) #0 { | ||
; WASM32-LABEL: test_sincos_f16: | ||
; WASM32: .functype test_sincos_f16 (i32, f32) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: call __extendhfsf2 | ||
; WASM32-NEXT: local.tee 1 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 2 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_f16: | ||
; WASM64: .functype test_sincos_f16 (i64, f32) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: call __extendhfsf2 | ||
; WASM64-NEXT: local.tee 1 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 2 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { half, half } @llvm.sincos.f16(half %a) | ||
ret { half, half } %result | ||
} | ||
|
||
define half @test_sincos_f16_only_use_sin(half %a) #0 { | ||
; CHECK-LABEL: test_sincos_f16_only_use_sin: | ||
; CHECK: .functype test_sincos_f16_only_use_sin (f32) -> (f32) | ||
; CHECK-NEXT: # %bb.0: | ||
; CHECK-NEXT: local.get 0 | ||
; CHECK-NEXT: call __truncsfhf2 | ||
; CHECK-NEXT: call __extendhfsf2 | ||
; CHECK-NEXT: call sinf | ||
; CHECK-NEXT: # fallthrough-return | ||
%result = call { half, half } @llvm.sincos.f16(half %a) | ||
%result.0 = extractvalue { half, half } %result, 0 | ||
ret half %result.0 | ||
} | ||
|
||
define half @test_sincos_f16_only_use_cos(half %a) #0 { | ||
; CHECK-LABEL: test_sincos_f16_only_use_cos: | ||
; CHECK: .functype test_sincos_f16_only_use_cos (f32) -> (f32) | ||
; CHECK-NEXT: # %bb.0: | ||
; CHECK-NEXT: local.get 0 | ||
; CHECK-NEXT: call __truncsfhf2 | ||
; CHECK-NEXT: call __extendhfsf2 | ||
; CHECK-NEXT: call cosf | ||
; CHECK-NEXT: # fallthrough-return | ||
%result = call { half, half } @llvm.sincos.f16(half %a) | ||
%result.1 = extractvalue { half, half } %result, 1 | ||
ret half %result.1 | ||
} | ||
|
||
define { <2 x half>, <2 x half> } @test_sincos_v2f16(<2 x half> %a) #0 { | ||
; WASM32-LABEL: test_sincos_v2f16: | ||
; WASM32: .functype test_sincos_v2f16 (i32, f32, f32) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: call __extendhfsf2 | ||
; WASM32-NEXT: local.tee 2 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 6 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: call __extendhfsf2 | ||
; WASM32-NEXT: local.tee 1 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 4 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 2 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: call __truncsfhf2 | ||
; WASM32-NEXT: i32.store16 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_v2f16: | ||
; WASM64: .functype test_sincos_v2f16 (i64, f32, f32) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: call __extendhfsf2 | ||
; WASM64-NEXT: local.tee 2 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 6 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: call __extendhfsf2 | ||
; WASM64-NEXT: local.tee 1 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 4 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 2 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: call __truncsfhf2 | ||
; WASM64-NEXT: i32.store16 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { <2 x half>, <2 x half> } @llvm.sincos.v2f16(<2 x half> %a) | ||
ret { <2 x half>, <2 x half> } %result | ||
} | ||
|
||
define { float, float } @test_sincos_f32(float %a) #0 { | ||
; WASM32-LABEL: test_sincos_f32: | ||
; WASM32: .functype test_sincos_f32 (i32, f32) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: f32.store 4 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: f32.store 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_f32: | ||
; WASM64: .functype test_sincos_f32 (i64, f32) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: f32.store 4 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: f32.store 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { float, float } @llvm.sincos.f32(float %a) | ||
ret { float, float } %result | ||
} | ||
|
||
define { <2 x float>, <2 x float> } @test_sincos_v2f32(<2 x float> %a) #0 { | ||
; WASM32-LABEL: test_sincos_v2f32: | ||
; WASM32: .functype test_sincos_v2f32 (i32, f32, f32) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: f32.store 12 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: f32.store 8 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: f32.store 4 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: f32.store 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_v2f32: | ||
; WASM64: .functype test_sincos_v2f32 (i64, f32, f32) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: f32.store 12 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: f32.store 8 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: f32.store 4 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: f32.store 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { <2 x float>, <2 x float> } @llvm.sincos.v2f32(<2 x float> %a) | ||
ret { <2 x float>, <2 x float> } %result | ||
} | ||
|
||
define { <3 x float>, <3 x float> } @test_sincos_v3f32(<3 x float> %a) #0 { | ||
; WASM32-LABEL: test_sincos_v3f32: | ||
; WASM32: .functype test_sincos_v3f32 (i32, f32, f32, f32) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 3 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: f32.store 24 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 3 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: f32.store 8 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: local.set 3 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call cosf | ||
; WASM32-NEXT: i32.reinterpret_f32 | ||
; WASM32-NEXT: i64.extend_i32_u | ||
; WASM32-NEXT: local.get 3 | ||
; WASM32-NEXT: i32.reinterpret_f32 | ||
; WASM32-NEXT: i64.extend_i32_u | ||
; WASM32-NEXT: i64.const 32 | ||
; WASM32-NEXT: i64.shl | ||
; WASM32-NEXT: i64.or | ||
; WASM32-NEXT: i64.store 16 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: local.set 3 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sinf | ||
; WASM32-NEXT: i32.reinterpret_f32 | ||
; WASM32-NEXT: i64.extend_i32_u | ||
; WASM32-NEXT: local.get 3 | ||
; WASM32-NEXT: i32.reinterpret_f32 | ||
; WASM32-NEXT: i64.extend_i32_u | ||
; WASM32-NEXT: i64.const 32 | ||
; WASM32-NEXT: i64.shl | ||
; WASM32-NEXT: i64.or | ||
; WASM32-NEXT: i64.store 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_v3f32: | ||
; WASM64: .functype test_sincos_v3f32 (i64, f32, f32, f32) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 3 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: f32.store 24 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 3 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: f32.store 8 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: local.set 3 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call cosf | ||
; WASM64-NEXT: i32.reinterpret_f32 | ||
; WASM64-NEXT: i64.extend_i32_u | ||
; WASM64-NEXT: local.get 3 | ||
; WASM64-NEXT: i32.reinterpret_f32 | ||
; WASM64-NEXT: i64.extend_i32_u | ||
; WASM64-NEXT: i64.const 32 | ||
; WASM64-NEXT: i64.shl | ||
; WASM64-NEXT: i64.or | ||
; WASM64-NEXT: i64.store 16 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: local.set 3 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sinf | ||
; WASM64-NEXT: i32.reinterpret_f32 | ||
; WASM64-NEXT: i64.extend_i32_u | ||
; WASM64-NEXT: local.get 3 | ||
; WASM64-NEXT: i32.reinterpret_f32 | ||
; WASM64-NEXT: i64.extend_i32_u | ||
; WASM64-NEXT: i64.const 32 | ||
; WASM64-NEXT: i64.shl | ||
; WASM64-NEXT: i64.or | ||
; WASM64-NEXT: i64.store 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { <3 x float>, <3 x float> } @llvm.sincos.v3f32(<3 x float> %a) | ||
ret { <3 x float>, <3 x float> } %result | ||
} | ||
|
||
define { double, double } @test_sincos_f64(double %a) #0 { | ||
; WASM32-LABEL: test_sincos_f64: | ||
; WASM32: .functype test_sincos_f64 (i32, f64) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call cos | ||
; WASM32-NEXT: f64.store 8 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sin | ||
; WASM32-NEXT: f64.store 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_f64: | ||
; WASM64: .functype test_sincos_f64 (i64, f64) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call cos | ||
; WASM64-NEXT: f64.store 8 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sin | ||
; WASM64-NEXT: f64.store 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { double, double } @llvm.sincos.f64(double %a) | ||
ret { double, double } %result | ||
} | ||
|
||
define { <2 x double>, <2 x double> } @test_sincos_v2f64(<2 x double> %a) #0 { | ||
; WASM32-LABEL: test_sincos_v2f64: | ||
; WASM32: .functype test_sincos_v2f64 (i32, f64, f64) -> () | ||
; WASM32-NEXT: # %bb.0: | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call cos | ||
; WASM32-NEXT: f64.store 24 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call cos | ||
; WASM32-NEXT: f64.store 16 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 2 | ||
; WASM32-NEXT: call sin | ||
; WASM32-NEXT: f64.store 8 | ||
; WASM32-NEXT: local.get 0 | ||
; WASM32-NEXT: local.get 1 | ||
; WASM32-NEXT: call sin | ||
; WASM32-NEXT: f64.store 0 | ||
; WASM32-NEXT: # fallthrough-return | ||
; | ||
; WASM64-LABEL: test_sincos_v2f64: | ||
; WASM64: .functype test_sincos_v2f64 (i64, f64, f64) -> () | ||
; WASM64-NEXT: # %bb.0: | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call cos | ||
; WASM64-NEXT: f64.store 24 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call cos | ||
; WASM64-NEXT: f64.store 16 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 2 | ||
; WASM64-NEXT: call sin | ||
; WASM64-NEXT: f64.store 8 | ||
; WASM64-NEXT: local.get 0 | ||
; WASM64-NEXT: local.get 1 | ||
; WASM64-NEXT: call sin | ||
; WASM64-NEXT: f64.store 0 | ||
; WASM64-NEXT: # fallthrough-return | ||
%result = call { <2 x double>, <2 x double> } @llvm.sincos.v2f64(<2 x double> %a) | ||
ret { <2 x double>, <2 x double> } %result | ||
} | ||
|
||
; ; FIXME: Asserts | ||
; define { fp128, fp128 } @test_sincos_f128(fp128 %a) #0 { | ||
; %result = call { fp128, fp128 } @llvm.sincos.f128(fp128 %a) | ||
; ret { fp128, fp128 } %result | ||
; } | ||
|
||
; ; FIXME: Asserts | ||
; define { <2 x fp128>, <2 x fp128> } @test_sincos_v2f128(<2 x fp128> %a) #0 { | ||
; %result = call { <2 x fp128>, <2 x fp128> } @llvm.sincos.v2f128(<2 x fp128> %a) | ||
; ret { <2 x fp128>, <2 x fp128> } %result | ||
; } | ||
|
||
attributes #0 = { nounwind } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where all the assertions actually generated in using this script?
What is the CHECKR2 label below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They're right there? CHECKR2 is dead check, I'll remove it