Skip to content

x86 f16: implement rounding support#1380

Open
TheNumbat wants to merge 3 commits intosimd-everywhere:masterfrom
TheNumbat:f16-rounding
Open

x86 f16: implement rounding support#1380
TheNumbat wants to merge 3 commits intosimd-everywhere:masterfrom
TheNumbat:f16-rounding

Conversation

@TheNumbat
Copy link
Contributor

@TheNumbat TheNumbat commented Jan 30, 2026

Makes _mm_cvtps_ph/_mm256_cvtps_ph respect the rounding mode argument. Assumes _MM_FROUND_CUR_DIRECTION is always half-to-even, which isn't strictly correct, but is already assumed by various other functions.

Enables the rounding mode tests and adds a few more. There should be no behavior changes for the round-nearest and round-current cases.

@mr-c
Copy link
Collaborator

mr-c commented Jan 31, 2026

Some errors from Microsoft Visual Studio 2015 version 19.00.24241.7 and Visual Studio 2017 version 19.16.27035:

https://ci.appveyor.com/project/nemequ/simde/builds/53462546/job/ya2shs5yojpisa31#L4688

../test/x86/f16c.c:101: assertion failed: r0[1] == simde_x_mm_loadu_epi16(test_vec[i].r0)[1] (-512 == 32256)
../test/x86/f16c.c:313: assertion failed: r0[1] == simde_x_mm_loadu_epi16(test_vec[i].r0)[1] (-512 == 32256)

@mr-c mr-c force-pushed the f16-rounding branch 2 times, most recently from 9e8035c to 234fb23 Compare February 1, 2026 11:53
@TheNumbat
Copy link
Contributor Author

TheNumbat commented Feb 2, 2026

Hmm, this is weird. It's rounding qnan to -qnan instead of qnan. Could be a compiler bug that was fixed in vs2019? Are there any other differences between those jobs?

@TheNumbat
Copy link
Contributor Author

The only difference from 19.14 to 19.20 (which gives the expected answer) seems to be some spills: https://godbolt.org/z/Y59G5vK65

@TheNumbat
Copy link
Contributor Author

Actually, it appears they changed NAN...https://godbolt.org/z/MGGfP5bfs

@TheNumbat
Copy link
Contributor Author

TheNumbat commented Feb 2, 2026

I just removed the test since signed nan handling already differs between targets

@mr-c mr-c force-pushed the f16-rounding branch 2 times, most recently from 42721ff to 7963426 Compare February 3, 2026 10:20
TheNumbat and others added 2 commits February 3, 2026 11:48
Assumes `_MM_FROUND_CUR_DIRECTION` is always half-to-even, which isn't strictly
correct, but is already assumed by various other functions.
@mr-c mr-c changed the title Implement f16 rounding modes x86 f16: implement rounding support Feb 3, 2026
@mr-c mr-c enabled auto-merge (rebase) February 3, 2026 20:02
auto-merge was automatically disabled February 4, 2026 16:24

Head branch was pushed to by a user without write access

@TheNumbat
Copy link
Contributor Author

Looks like the Azure CI pipeline started timing out?

@mr-c
Copy link
Collaborator

mr-c commented Feb 5, 2026

@TheNumbat I will rebase this PR once #1384 is merged

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.

2 participants