Skip to content

Conversation

@filipnavara
Copy link
Member

Fixes #97922

I decided to go for managed implementation to make it trimmable.

@ghost ghost added area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member labels Feb 5, 2024
@ghost
Copy link

ghost commented Feb 5, 2024

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #97922

I decided to go for managed implementation to make it trimmable.

Author: filipnavara
Assignees: -
Labels:

area-NativeAOT-coreclr

Milestone: -

@jkotas
Copy link
Member

jkotas commented Feb 5, 2024

Does this work with Scanner? Can the implementation just call Math.Round instead?

I do not understand why we need these JIT intrinsics in the first place. They seem to be only used on Arm and only to morph System.Math.Round. What would break if these JIT intrinsics are deleted?

cc @dotnet/jit-contrib

@filipnavara
Copy link
Member Author

ARM doesn't have native instructions to perform the rounding (unlike eg. ARM64). I didn't realize there is actually already a managed implementation in Math.cs. I suppose it can be used.

@EgorBo
Copy link
Member

EgorBo commented Feb 5, 2024

ARM doesn't have native instructions to perform the rounding (unlike eg. ARM64). I didn't realize there is actually already a managed implementation in Math.cs. I suppose it can be used.

Even if there were no managed impl, it could still just go the InternalCall path like most Math APIs.

I wasn't able to track who and why added those, looks like it happened before the Initial commit to populate CoreCLR repo commit.

@filipnavara
Copy link
Member Author

Even if there were no managed impl, it could still just go the InternalCall path like most Math APIs.

The roundeven native function is not available on all supported platforms. Thus we cannot use it. It was only added in C23 standard, glibc 2.25, and it’s not present on MUSL and Bionic libc.

@MichalPetryka
Copy link
Contributor

Even if there were no managed impl, it could still just go the InternalCall path like most Math APIs.

The roundeven native function is not available on all supported platforms. Thus we cannot use it. It was only added in C23 standard, glibc 2.25, and it’s not present on MUSL and Bionic libc.

Does doing

fesetround(FE_TONEAREST);
return rintf(f);

instead not work?

@filipnavara
Copy link
Member Author

filipnavara commented Feb 5, 2024

fesetround(FE_TONEAREST); could possibly work too, but if there is existing managed implementation I think it’s easier to just delete intrinsic code path altogether.

@jkotas
Copy link
Member

jkotas commented Feb 5, 2024

I wasn't able to track who and why added those, looks like it happened before the Initial commit to populate CoreCLR repo commit.

It is likely a left over from the times before we had support for recognizing managed methods as JIT intrinsics where all JIT intrinsics had to be FCalls.

CORINFO_HELP_DBL2ULNG_OVF,
CORINFO_HELP_FLTREM,
CORINFO_HELP_DBLREM,
CORINFO_HELP_FLTROUND,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs new JIT/EE interface GUID

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I can remove it without removing the R2R helpers due to how it's mapped in the VM code. If the CI passes I can add comment for the next person to remove it.

@tannergooding
Copy link
Member

Worth noting as well that fesetround(FE_TONEAREST); should be completely unnecessary, as we already do not support the user changing the default rounding mode. It is strictly undefined behavior if they do. nearbyint is notably better than rint, typically, but as we don't support IEEE 754 exception handling and likewise treat enabling it as UB, they should generally behave the same.

However, I also agree that having this in managed is ultimately better. Our currently implementation is notably not super efficient and we could improve it, but that can be a separate work item.

@jkotas
Copy link
Member

jkotas commented Feb 5, 2024

Build break during crossgen: Assertion failed 'unreached' in 'System.Math:IEEERemainder(double,double):double' during 'Linear scan register alloc' (IL size 150; hash 0xdbe0c805; FullOpts)

@jkotas
Copy link
Member

jkotas commented Feb 5, 2024

I think it is also safe to delete the references in jit\valuenum.*, including FltRound/DblRound VNs.

@ryujit-bot
Copy link

Diff results for #97964

Assembly diffs

Assembly diffs for linux/arm64 ran on windows/x64

Diffs are based on 134,774 contexts (18,569 MinOpts, 116,205 FullOpts).

MISSED contexts: base: 1 (0.00%), diff: 111,892 (44.67%)

Overall (-65,128 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm64.checked.mch 254,108 -6,996
benchmarks.run_pgo.linux.arm64.checked.mch 1,175,000 -4,220
benchmarks.run_tiered.linux.arm64.checked.mch 1,217,436 -10,432
coreclr_tests.run.linux.arm64.checked.mch 85,076 -872
libraries.crossgen2.linux.arm64.checked.mch 9,628,520 -24
libraries.pmi.linux.arm64.checked.mch 479,152 -11,220
libraries_tests.run.linux.arm64.Release.mch 705,512 -3,148
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch 96,188 -4,340
realworld.run.linux.arm64.checked.mch 418,800 -12,572
smoke_tests.nativeaot.linux.arm64.checked.mch 810,696 -11,304
MinOpts (-15,224 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.linux.arm64.checked.mch 842,584 -4,120
benchmarks.run_tiered.linux.arm64.checked.mch 1,078,572 -8,036
libraries_tests.run.linux.arm64.Release.mch 520,532 -3,068
FullOpts (-49,904 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm64.checked.mch 244,632 -6,996
benchmarks.run_pgo.linux.arm64.checked.mch 332,416 -100
benchmarks.run_tiered.linux.arm64.checked.mch 138,864 -2,396
coreclr_tests.run.linux.arm64.checked.mch 85,076 -872
libraries.crossgen2.linux.arm64.checked.mch 9,627,248 -24
libraries.pmi.linux.arm64.checked.mch 479,152 -11,220
libraries_tests.run.linux.arm64.Release.mch 184,980 -80
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch 96,188 -4,340
realworld.run.linux.arm64.checked.mch 411,572 -12,572
smoke_tests.nativeaot.linux.arm64.checked.mch 810,508 -11,304

Assembly diffs for linux/x64 ran on windows/x64

Diffs are based on 136,302 contexts (18,734 MinOpts, 117,568 FullOpts).

MISSED contexts: base: 2 (0.00%), diff: 116,512 (45.38%)

Overall (-60,804 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.x64.checked.mch 140,354 -3,053
benchmarks.run_pgo.linux.x64.checked.mch 948,560 -4,385
benchmarks.run_tiered.linux.x64.checked.mch 796,003 -9,435
coreclr_tests.run.linux.x64.checked.mch 165,738 -740
libraries.crossgen2.linux.x64.checked.mch 7,809,464 -17
libraries.pmi.linux.x64.checked.mch 117,804 -20,220
libraries_tests.run.linux.x64.Release.mch 619,081 -2,891
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch 67,726 -3,412
realworld.run.linux.x64.checked.mch 361,633 -10,882
smoke_tests.nativeaot.linux.x64.checked.mch 411,097 -5,769
MinOpts (-15,022 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.linux.x64.checked.mch 648,791 -4,385
benchmarks.run_tiered.linux.x64.checked.mch 697,606 -7,426
coreclr_tests.run.linux.x64.checked.mch 133,568 -532
libraries_tests.run.linux.x64.Release.mch 374,137 -2,679
FullOpts (-45,782 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.x64.checked.mch 140,354 -3,053
benchmarks.run_tiered.linux.x64.checked.mch 98,397 -2,009
coreclr_tests.run.linux.x64.checked.mch 32,170 -208
libraries.crossgen2.linux.x64.checked.mch 7,808,513 -17
libraries.pmi.linux.x64.checked.mch 117,804 -20,220
libraries_tests.run.linux.x64.Release.mch 244,944 -212
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch 67,726 -3,412
realworld.run.linux.x64.checked.mch 361,633 -10,882
smoke_tests.nativeaot.linux.x64.checked.mch 411,015 -5,769

Assembly diffs for osx/arm64 ran on windows/x64

Diffs are based on 143,750 contexts (21,411 MinOpts, 122,339 FullOpts).

MISSED contexts: base: 4 (0.00%), diff: 124,661 (45.84%)

Overall (-40,932 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.osx.arm64.checked.mch 189,868 -3,036
benchmarks.run_pgo.osx.arm64.checked.mch 1,297,204 -7,836
benchmarks.run_tiered.osx.arm64.checked.mch 1,037,520 -6,696
coreclr_tests.run.osx.arm64.checked.mch 247,160 -776
libraries.crossgen2.osx.arm64.checked.mch 11,447,832 -40
libraries.pmi.osx.arm64.checked.mch 708,248 -3,484
libraries_tests.run.osx.arm64.Release.mch 649,232 -2,956
libraries_tests_no_tiered_compilation.run.osx.arm64.Release.mch 102,104 -4,316
realworld.run.osx.arm64.checked.mch 402,548 -11,792
MinOpts (-17,532 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.osx.arm64.checked.mch 1,201,340 -7,816
benchmarks.run_tiered.osx.arm64.checked.mch 903,596 -6,344
coreclr_tests.run.osx.arm64.checked.mch 222,648 -480
libraries_tests.run.osx.arm64.Release.mch 597,968 -2,892
FullOpts (-23,400 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.osx.arm64.checked.mch 189,868 -3,036
benchmarks.run_pgo.osx.arm64.checked.mch 95,864 -20
benchmarks.run_tiered.osx.arm64.checked.mch 133,924 -352
coreclr_tests.run.osx.arm64.checked.mch 24,512 -296
libraries.crossgen2.osx.arm64.checked.mch 11,446,560 -40
libraries.pmi.osx.arm64.checked.mch 708,248 -3,484
libraries_tests.run.osx.arm64.Release.mch 51,264 -64
libraries_tests_no_tiered_compilation.run.osx.arm64.Release.mch 102,104 -4,316
realworld.run.osx.arm64.checked.mch 402,548 -11,792

Assembly diffs for windows/arm64 ran on windows/x64

Diffs are based on 132,266 contexts (15,289 MinOpts, 116,977 FullOpts).

MISSED contexts: base: 3 (0.00%), diff: 115,590 (45.92%)

Overall (-61,336 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.windows.arm64.checked.mch 182,012 -2,820
benchmarks.run_pgo.windows.arm64.checked.mch 1,173,228 -6,688
benchmarks.run_tiered.windows.arm64.checked.mch 862,284 -7,268
coreclr_tests.run.windows.arm64.checked.mch 77,860 -676
libraries.crossgen2.windows.arm64.checked.mch 10,005,180 -76
libraries.pmi.windows.arm64.checked.mch 381,864 -8,852
libraries_tests.run.windows.arm64.Release.mch 334,372 -1,272
libraries_tests_no_tiered_compilation.run.windows.arm64.Release.mch 98,900 -4,260
realworld.run.windows.arm64.checked.mch 400,564 -11,784
smoke_tests.nativeaot.windows.arm64.checked.mch 1,012,896 -17,640
MinOpts (-13,448 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.windows.arm64.checked.mch 974,380 -6,476
benchmarks.run_tiered.windows.arm64.checked.mch 736,852 -5,780
libraries_tests.run.windows.arm64.Release.mch 241,184 -1,192
FullOpts (-47,888 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.windows.arm64.checked.mch 182,012 -2,820
benchmarks.run_pgo.windows.arm64.checked.mch 198,848 -212
benchmarks.run_tiered.windows.arm64.checked.mch 125,432 -1,488
coreclr_tests.run.windows.arm64.checked.mch 77,860 -676
libraries.crossgen2.windows.arm64.checked.mch 10,004,164 -76
libraries.pmi.windows.arm64.checked.mch 381,864 -8,852
libraries_tests.run.windows.arm64.Release.mch 93,188 -80
libraries_tests_no_tiered_compilation.run.windows.arm64.Release.mch 98,900 -4,260
realworld.run.windows.arm64.checked.mch 400,564 -11,784
smoke_tests.nativeaot.windows.arm64.checked.mch 1,012,684 -17,640

Assembly diffs for windows/x64 ran on windows/x64

Diffs are based on 135,677 contexts (21,464 MinOpts, 114,213 FullOpts).

MISSED contexts: base: 1 (0.00%), diff: 120,821 (46.32%)

Overall (-82,504 bytes)
Collection Base size (bytes) Diff size (bytes)
aspnet.run.windows.x64.checked.mch 514,620 -8,573
benchmarks.run.windows.x64.checked.mch 125,820 -3,462
benchmarks.run_pgo.windows.x64.checked.mch 877,224 -6,482
benchmarks.run_tiered.windows.x64.checked.mch 758,568 -9,407
coreclr_tests.run.windows.x64.checked.mch 51,809 -514
libraries.crossgen2.windows.x64.checked.mch 6,763,269 -61
libraries.pmi.windows.x64.checked.mch 104,569 -26,214
libraries_tests.run.windows.x64.Release.mch 406,472 -2,539
libraries_tests_no_tiered_compilation.run.windows.x64.Release.mch 68,102 -3,732
realworld.run.windows.x64.checked.mch 433,308 -10,928
smoke_tests.nativeaot.windows.x64.checked.mch 453,425 -10,592
MinOpts (-18,807 bytes)
Collection Base size (bytes) Diff size (bytes)
aspnet.run.windows.x64.checked.mch 333,087 -2,957
benchmarks.run_pgo.windows.x64.checked.mch 624,409 -6,359
benchmarks.run_tiered.windows.x64.checked.mch 674,908 -7,044
libraries_tests.run.windows.x64.Release.mch 326,705 -2,447
FullOpts (-63,697 bytes)
Collection Base size (bytes) Diff size (bytes)
aspnet.run.windows.x64.checked.mch 181,533 -5,616
benchmarks.run.windows.x64.checked.mch 125,746 -3,462
benchmarks.run_pgo.windows.x64.checked.mch 252,815 -123
benchmarks.run_tiered.windows.x64.checked.mch 83,660 -2,363
coreclr_tests.run.windows.x64.checked.mch 51,809 -514
libraries.crossgen2.windows.x64.checked.mch 6,762,519 -61
libraries.pmi.windows.x64.checked.mch 104,569 -26,214
libraries_tests.run.windows.x64.Release.mch 79,767 -92
libraries_tests_no_tiered_compilation.run.windows.x64.Release.mch 68,102 -3,732
realworld.run.windows.x64.checked.mch 433,308 -10,928
smoke_tests.nativeaot.windows.x64.checked.mch 453,379 -10,592

Details here


Assembly diffs for linux/arm ran on windows/x86

Diffs are based on 104,802 contexts (10,727 MinOpts, 94,075 FullOpts).

MISSED contexts: base: 826 (0.42%), diff: 90,575 (45.53%)

Overall (-47,582 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 181,946 -5,784
benchmarks.run_pgo.linux.arm.checked.mch 756,482 -2,682
benchmarks.run_tiered.linux.arm.checked.mch 610,796 -6,806
coreclr_tests.run.linux.arm.checked.mch 295,714 -1,684
libraries.crossgen2.linux.arm.checked.mch 5,931,272 -10
libraries.pmi.linux.arm.checked.mch 578,368 -11,164
libraries_tests.run.linux.arm.Release.mch 298,006 -1,746
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 59,390 -4,270
realworld.run.linux.arm.checked.mch 1,727,516 -13,436
MinOpts (-7,502 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.linux.arm.checked.mch 264,396 -2,394
benchmarks.run_tiered.linux.arm.checked.mch 428,430 -3,448
coreclr_tests.run.linux.arm.checked.mch 219,190 -596
libraries_tests.run.linux.arm.Release.mch 163,882 -1,064
FullOpts (-40,080 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 177,482 -5,784
benchmarks.run_pgo.linux.arm.checked.mch 492,086 -288
benchmarks.run_tiered.linux.arm.checked.mch 182,366 -3,358
coreclr_tests.run.linux.arm.checked.mch 76,524 -1,088
libraries.crossgen2.linux.arm.checked.mch 5,930,504 -10
libraries.pmi.linux.arm.checked.mch 578,368 -11,164
libraries_tests.run.linux.arm.Release.mch 134,124 -682
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 59,390 -4,270
realworld.run.linux.arm.checked.mch 1,723,000 -13,436

Assembly diffs for windows/x86 ran on windows/x86

Diffs are based on 113,735 contexts (7,938 MinOpts, 105,797 FullOpts).

MISSED contexts: base: 47 (0.02%), diff: 100,776 (46.21%)

Overall (-28,228 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.windows.x86.checked.mch 121,260 -2,786
benchmarks.run_pgo.windows.x86.checked.mch 446,652 -2,055
benchmarks.run_tiered.windows.x86.checked.mch 340,626 -2,933
coreclr_tests.run.windows.x86.checked.mch 23,513 -666
libraries.crossgen2.windows.x86.checked.mch 5,347,103 -27
libraries.pmi.windows.x86.checked.mch 792,946 -5,465
libraries_tests.run.windows.x86.Release.mch 194,262 -913
libraries_tests_no_tiered_compilation.run.windows.x86.Release.mch 51,784 -2,737
realworld.run.windows.x86.checked.mch 374,068 -10,646
MinOpts (-4,257 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run_pgo.windows.x86.checked.mch 262,554 -1,827
benchmarks.run_tiered.windows.x86.checked.mch 248,044 -1,645
libraries_tests.run.windows.x86.Release.mch 116,463 -785
FullOpts (-23,971 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.windows.x86.checked.mch 121,203 -2,786
benchmarks.run_pgo.windows.x86.checked.mch 184,098 -228
benchmarks.run_tiered.windows.x86.checked.mch 92,582 -1,288
coreclr_tests.run.windows.x86.checked.mch 23,513 -666
libraries.crossgen2.windows.x86.checked.mch 5,346,412 -27
libraries.pmi.windows.x86.checked.mch 792,946 -5,465
libraries_tests.run.windows.x86.Release.mch 77,799 -128
libraries_tests_no_tiered_compilation.run.windows.x86.Release.mch 51,784 -2,737
realworld.run.windows.x86.checked.mch 374,068 -10,646

Details here


Throughput diffs

Throughput diffs for linux/arm64 ran on linux/x64

Overall (-2.07% to -0.04%)
Collection PDIFF
benchmarks.run.linux.arm64.checked.mch -1.69%
benchmarks.run_pgo.linux.arm64.checked.mch -0.15%
benchmarks.run_tiered.linux.arm64.checked.mch -0.79%
coreclr_tests.run.linux.arm64.checked.mch -0.30%
libraries.crossgen2.linux.arm64.checked.mch -0.04%
libraries.pmi.linux.arm64.checked.mch -2.07%
libraries_tests.run.linux.arm64.Release.mch -0.13%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch -1.91%
realworld.run.linux.arm64.checked.mch -1.87%
smoke_tests.nativeaot.linux.arm64.checked.mch -0.57%
MinOpts (-0.68% to +0.00%)
Collection PDIFF
benchmarks.run.linux.arm64.checked.mch -0.02%
benchmarks.run_pgo.linux.arm64.checked.mch -0.65%
benchmarks.run_tiered.linux.arm64.checked.mch -0.68%
coreclr_tests.run.linux.arm64.checked.mch -0.03%
libraries_tests.run.linux.arm64.Release.mch -0.32%
FullOpts (-2.07% to -0.03%)
Collection PDIFF
benchmarks.run.linux.arm64.checked.mch -1.73%
benchmarks.run_pgo.linux.arm64.checked.mch -0.09%
benchmarks.run_tiered.linux.arm64.checked.mch -0.94%
coreclr_tests.run.linux.arm64.checked.mch -0.32%
libraries.crossgen2.linux.arm64.checked.mch -0.04%
libraries.pmi.linux.arm64.checked.mch -2.07%
libraries_tests.run.linux.arm64.Release.mch -0.03%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch -1.91%
realworld.run.linux.arm64.checked.mch -1.94%
smoke_tests.nativeaot.linux.arm64.checked.mch -0.57%

Throughput diffs for linux/x64 ran on linux/x64

Overall (-2.70% to -0.04%)
Collection PDIFF
benchmarks.run.linux.x64.checked.mch -1.53%
benchmarks.run_pgo.linux.x64.checked.mch -0.14%
benchmarks.run_tiered.linux.x64.checked.mch -0.71%
coreclr_tests.run.linux.x64.checked.mch -0.16%
libraries.crossgen2.linux.x64.checked.mch -0.04%
libraries.pmi.linux.x64.checked.mch -2.70%
libraries_tests.run.linux.x64.Release.mch -0.09%
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch -1.83%
realworld.run.linux.x64.checked.mch -1.80%
smoke_tests.nativeaot.linux.x64.checked.mch -0.47%
MinOpts (-0.69% to 0.00%)
Collection PDIFF
benchmarks.run.linux.x64.checked.mch -0.01%
benchmarks.run_pgo.linux.x64.checked.mch -0.69%
benchmarks.run_tiered.linux.x64.checked.mch -0.68%
coreclr_tests.run.linux.x64.checked.mch -0.16%
libraries_tests.run.linux.x64.Release.mch -0.36%
FullOpts (-2.70% to -0.02%)
Collection PDIFF
benchmarks.run.linux.x64.checked.mch -1.57%
benchmarks.run_pgo.linux.x64.checked.mch -0.09%
benchmarks.run_tiered.linux.x64.checked.mch -0.76%
coreclr_tests.run.linux.x64.checked.mch -0.16%
libraries.crossgen2.linux.x64.checked.mch -0.04%
libraries.pmi.linux.x64.checked.mch -2.70%
libraries_tests.run.linux.x64.Release.mch -0.02%
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch -1.83%
realworld.run.linux.x64.checked.mch -1.85%
smoke_tests.nativeaot.linux.x64.checked.mch -0.47%

Throughput diffs for osx/arm64 ran on linux/x64

Overall (-1.99% to -0.04%)
Collection PDIFF
benchmarks.run.osx.arm64.checked.mch -1.77%
benchmarks.run_pgo.osx.arm64.checked.mch -0.32%
benchmarks.run_tiered.osx.arm64.checked.mch -0.77%
coreclr_tests.run.osx.arm64.checked.mch -0.09%
libraries.crossgen2.osx.arm64.checked.mch -0.04%
libraries.pmi.osx.arm64.checked.mch -1.99%
libraries_tests.run.osx.arm64.Release.mch -0.23%
libraries_tests_no_tiered_compilation.run.osx.arm64.Release.mch -1.86%
realworld.run.osx.arm64.checked.mch -1.85%
MinOpts (-0.70% to +0.00%)
Collection PDIFF
benchmarks.run_pgo.osx.arm64.checked.mch -0.65%
benchmarks.run_tiered.osx.arm64.checked.mch -0.70%
coreclr_tests.run.osx.arm64.checked.mch -0.06%
libraries_tests.run.osx.arm64.Release.mch -0.22%
FullOpts (-1.99% to -0.04%)
Collection PDIFF
benchmarks.run.osx.arm64.checked.mch -1.77%
benchmarks.run_pgo.osx.arm64.checked.mch -0.19%
benchmarks.run_tiered.osx.arm64.checked.mch -0.90%
coreclr_tests.run.osx.arm64.checked.mch -0.36%
libraries.crossgen2.osx.arm64.checked.mch -0.04%
libraries.pmi.osx.arm64.checked.mch -1.99%
libraries_tests.run.osx.arm64.Release.mch -0.25%
libraries_tests_no_tiered_compilation.run.osx.arm64.Release.mch -1.86%
realworld.run.osx.arm64.checked.mch -1.93%

Throughput diffs for windows/arm64 ran on linux/x64

Overall (-3.23% to -0.05%)
Collection PDIFF
benchmarks.run.windows.arm64.checked.mch -1.80%
benchmarks.run_pgo.windows.arm64.checked.mch -0.31%
benchmarks.run_tiered.windows.arm64.checked.mch -0.87%
coreclr_tests.run.windows.arm64.checked.mch -0.51%
libraries.crossgen2.windows.arm64.checked.mch -0.05%
libraries.pmi.windows.arm64.checked.mch -3.23%
libraries_tests.run.windows.arm64.Release.mch -0.11%
libraries_tests_no_tiered_compilation.run.windows.arm64.Release.mch -1.86%
realworld.run.windows.arm64.checked.mch -1.89%
smoke_tests.nativeaot.windows.arm64.checked.mch -0.76%
MinOpts (-0.69% to +0.00%)
Collection PDIFF
benchmarks.run_pgo.windows.arm64.checked.mch -0.69%
benchmarks.run_tiered.windows.arm64.checked.mch -0.69%
coreclr_tests.run.windows.arm64.checked.mch -0.10%
libraries_tests.run.windows.arm64.Release.mch -0.41%
FullOpts (-3.23% to -0.03%)
Collection PDIFF
benchmarks.run.windows.arm64.checked.mch -1.80%
benchmarks.run_pgo.windows.arm64.checked.mch -0.22%
benchmarks.run_tiered.windows.arm64.checked.mch -1.15%
coreclr_tests.run.windows.arm64.checked.mch -0.51%
libraries.crossgen2.windows.arm64.checked.mch -0.05%
libraries.pmi.windows.arm64.checked.mch -3.23%
libraries_tests.run.windows.arm64.Release.mch -0.03%
libraries_tests_no_tiered_compilation.run.windows.arm64.Release.mch -1.86%
realworld.run.windows.arm64.checked.mch -1.96%
smoke_tests.nativeaot.windows.arm64.checked.mch -0.76%

Throughput diffs for windows/x64 ran on linux/x64

Overall (-6.05% to -0.46%)
Collection PDIFF
aspnet.run.windows.x64.checked.mch -2.22%
benchmarks.run.windows.x64.checked.mch -4.01%
benchmarks.run_pgo.windows.x64.checked.mch -0.46%
benchmarks.run_tiered.windows.x64.checked.mch -1.51%
coreclr_tests.run.windows.x64.checked.mch -3.74%
libraries.crossgen2.windows.x64.checked.mch -0.65%
libraries.pmi.windows.x64.checked.mch -6.05%
libraries_tests.run.windows.x64.Release.mch -1.89%
libraries_tests_no_tiered_compilation.run.windows.x64.Release.mch -5.70%
realworld.run.windows.x64.checked.mch -2.73%
smoke_tests.nativeaot.windows.x64.checked.mch -1.70%
MinOpts (-78.15% to 0.00%)
Collection PDIFF
aspnet.run.windows.x64.checked.mch -4.46%
benchmarks.run_pgo.windows.x64.checked.mch -2.17%
benchmarks.run_tiered.windows.x64.checked.mch -1.82%
coreclr_tests.run.windows.x64.checked.mch -78.15%
libraries_tests.run.windows.x64.Release.mch -2.73%
FullOpts (-6.05% to -0.20%)
Collection PDIFF
aspnet.run.windows.x64.checked.mch -1.66%
benchmarks.run.windows.x64.checked.mch -4.01%
benchmarks.run_pgo.windows.x64.checked.mch -0.20%
benchmarks.run_tiered.windows.x64.checked.mch -1.10%
coreclr_tests.run.windows.x64.checked.mch -1.05%
libraries.crossgen2.windows.x64.checked.mch -0.65%
libraries.pmi.windows.x64.checked.mch -6.05%
libraries_tests.run.windows.x64.Release.mch -0.61%
libraries_tests_no_tiered_compilation.run.windows.x64.Release.mch -5.70%
realworld.run.windows.x64.checked.mch -2.73%
smoke_tests.nativeaot.windows.x64.checked.mch -1.70%

Details here


@filipnavara
Copy link
Member Author

Build break during crossgen: Assertion failed 'unreached' in 'System.Math:IEEERemainder(double,double):double' during 'Linear scan register alloc' (IL size 150; hash 0xdbe0c805; FullOpts)

This will take me a little while to understand and resolve.

@SingleAccretion
Copy link
Contributor

@filipnavara I think you need to take out NI_System_Math_Round from here:

switch (intrinsicName)
{
case NI_System_Math_Abs:
case NI_System_Math_Round:
case NI_System_Math_Sqrt:
return true;

@filipnavara filipnavara changed the title [NativeAOT] Implement roundeven[f] in managed code [ARM] Use Math[F].Round implementation in managed code Feb 5, 2024
filipnavara and others added 2 commits February 5, 2024 21:35
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
@ryujit-bot
Copy link

Diff results for #97964

Throughput diffs

Throughput diffs for linux/arm64 ran on linux/x64

Overall (-5.00% to -0.15%)
Collection PDIFF
smoke_tests.nativeaot.linux.arm64.checked.mch -0.53%
libraries.crossgen2.linux.arm64.checked.mch -0.15%
libraries_tests.run.linux.arm64.Release.mch -1.90%
libraries.pmi.linux.arm64.checked.mch -0.40%
coreclr_tests.run.linux.arm64.checked.mch -0.93%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch -5.00%
benchmarks.run_pgo.linux.arm64.checked.mch -0.21%
benchmarks.run_tiered.linux.arm64.checked.mch -0.23%
MinOpts (-2.88% to 0.00%)
Collection PDIFF
libraries_tests.run.linux.arm64.Release.mch -2.88%
benchmarks.run_pgo.linux.arm64.checked.mch -0.25%
benchmarks.run_tiered.linux.arm64.checked.mch -0.28%
FullOpts (-5.00% to +0.00%)
Collection PDIFF
smoke_tests.nativeaot.linux.arm64.checked.mch -0.53%
libraries.crossgen2.linux.arm64.checked.mch -0.15%
libraries.pmi.linux.arm64.checked.mch -0.40%
coreclr_tests.run.linux.arm64.checked.mch -0.93%
libraries_tests_no_tiered_compilation.run.linux.arm64.Release.mch -5.00%
benchmarks.run_tiered.linux.arm64.checked.mch -0.18%

Throughput diffs for linux/x64 ran on linux/x64

Overall (-5.74% to -0.01%)
Collection PDIFF
benchmarks.run_tiered.linux.x64.checked.mch -0.36%
libraries_tests.run.linux.x64.Release.mch -0.54%
smoke_tests.nativeaot.linux.x64.checked.mch -0.49%
benchmarks.run_pgo.linux.x64.checked.mch -0.54%
coreclr_tests.run.linux.x64.checked.mch -0.10%
libraries.pmi.linux.x64.checked.mch -1.57%
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch -5.74%
libraries.crossgen2.linux.x64.checked.mch -0.01%
MinOpts (-0.67% to 0.00%)
Collection PDIFF
benchmarks.run_tiered.linux.x64.checked.mch -0.64%
libraries_tests.run.linux.x64.Release.mch -0.67%
benchmarks.run_pgo.linux.x64.checked.mch -0.20%
coreclr_tests.run.linux.x64.checked.mch -0.26%
FullOpts (-5.74% to +0.01%)
Collection PDIFF
libraries_tests.run.linux.x64.Release.mch +0.01%
smoke_tests.nativeaot.linux.x64.checked.mch -0.49%
benchmarks.run_pgo.linux.x64.checked.mch -1.24%
libraries.pmi.linux.x64.checked.mch -1.57%
libraries_tests_no_tiered_compilation.run.linux.x64.Release.mch -5.74%
libraries.crossgen2.linux.x64.checked.mch -0.01%

Details here


Throughput diffs for linux/arm ran on windows/x86

Overall (-2.94% to -0.03%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch -1.23%
benchmarks.run_pgo.linux.arm.checked.mch -0.03%
benchmarks.run_tiered.linux.arm.checked.mch -0.70%
coreclr_tests.run.linux.arm.checked.mch -0.38%
libraries.crossgen2.linux.arm.checked.mch -0.04%
libraries.pmi.linux.arm.checked.mch -2.94%
libraries_tests.run.linux.arm.Release.mch -0.28%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch -1.95%
realworld.run.linux.arm.checked.mch -0.86%
MinOpts (-0.63% to 0.00%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch -0.01%
benchmarks.run_pgo.linux.arm.checked.mch -0.63%
benchmarks.run_tiered.linux.arm.checked.mch -0.60%
coreclr_tests.run.linux.arm.checked.mch -0.21%
libraries_tests.run.linux.arm.Release.mch -0.45%
FullOpts (-2.94% to -0.01%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch -1.32%
benchmarks.run_pgo.linux.arm.checked.mch -0.01%
benchmarks.run_tiered.linux.arm.checked.mch -0.76%
coreclr_tests.run.linux.arm.checked.mch -0.69%
libraries.crossgen2.linux.arm.checked.mch -0.04%
libraries.pmi.linux.arm.checked.mch -2.94%
libraries_tests.run.linux.arm.Release.mch -0.27%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch -1.95%
realworld.run.linux.arm.checked.mch -0.86%

Throughput diffs for windows/x86 ran on windows/x86

Overall (-1.93% to -0.05%)
Collection PDIFF
benchmarks.run.windows.x86.checked.mch -1.37%
benchmarks.run_pgo.windows.x86.checked.mch -0.50%
benchmarks.run_tiered.windows.x86.checked.mch -0.83%
coreclr_tests.run.windows.x86.checked.mch -0.38%
libraries.crossgen2.windows.x86.checked.mch -0.05%
libraries.pmi.windows.x86.checked.mch -1.66%
libraries_tests.run.windows.x86.Release.mch -0.26%
libraries_tests_no_tiered_compilation.run.windows.x86.Release.mch -1.88%
realworld.run.windows.x86.checked.mch -1.93%
MinOpts (-0.56% to 0.00%)
Collection PDIFF
benchmarks.run_pgo.windows.x86.checked.mch -0.56%
benchmarks.run_tiered.windows.x86.checked.mch -0.53%
coreclr_tests.run.windows.x86.checked.mch -0.19%
libraries_tests.run.windows.x86.Release.mch -0.18%
FullOpts (-1.93% to -0.05%)
Collection PDIFF
benchmarks.run.windows.x86.checked.mch -1.37%
benchmarks.run_pgo.windows.x86.checked.mch -0.48%
benchmarks.run_tiered.windows.x86.checked.mch -1.06%
coreclr_tests.run.windows.x86.checked.mch -0.38%
libraries.crossgen2.windows.x86.checked.mch -0.05%
libraries.pmi.windows.x86.checked.mch -1.66%
libraries_tests.run.windows.x86.Release.mch -0.30%
libraries_tests_no_tiered_compilation.run.windows.x86.Release.mch -1.88%
realworld.run.windows.x86.checked.mch -1.93%

Details here


Copy link
Member

@jkotas jkotas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks

@ryujit-bot
Copy link

Diff results for #97964

Assembly diffs

Assembly diffs for linux/arm ran on windows/x86

Diffs are based on 1,450,643 contexts (345,734 MinOpts, 1,104,909 FullOpts).

MISSED contexts: base: 53,862 (3.58%), diff: 54,343 (3.61%)

Overall (-4,886 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 13,712,182 -38
coreclr_tests.run.linux.arm.checked.mch 321,358,662 -3,940
libraries.pmi.linux.arm.checked.mch 49,904,152 -38
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 94,495,714 -776
realworld.run.linux.arm.checked.mch 13,599,632 -94
FullOpts (-4,886 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 13,399,606 -38
coreclr_tests.run.linux.arm.checked.mch 108,923,712 -3,940
libraries.pmi.linux.arm.checked.mch 49,797,928 -38
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 84,465,944 -776
realworld.run.linux.arm.checked.mch 13,164,560 -94

Details here


Throughput diffs

Throughput diffs for linux/arm ran on windows/x86

Overall (+0.03%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.03%
libraries.crossgen2.linux.arm.checked.mch +0.03%
libraries.pmi.linux.arm.checked.mch +0.03%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%
MinOpts (+0.02% to +0.04%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.03%
libraries.crossgen2.linux.arm.checked.mch +0.02%
libraries.pmi.linux.arm.checked.mch +0.04%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%
FullOpts (+0.03% to +0.04%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.04%
libraries.crossgen2.linux.arm.checked.mch +0.03%
libraries.pmi.linux.arm.checked.mch +0.03%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%

Details here


Throughput diffs for linux/arm64 ran on linux/x64

Overall (+0.00% to +0.01%)
Collection PDIFF
benchmarks.run_pgo.linux.arm64.checked.mch +0.01%
FullOpts (+0.00% to +0.01%)
Collection PDIFF
libraries_tests.run.linux.arm64.Release.mch +0.01%
benchmarks.run_pgo.linux.arm64.checked.mch +0.01%

Details here


@ryujit-bot
Copy link

Diff results for #97964

Assembly diffs

Assembly diffs for linux/arm ran on windows/x86

Diffs are based on 1,450,643 contexts (345,734 MinOpts, 1,104,909 FullOpts).

MISSED contexts: base: 53,862 (3.58%), diff: 54,343 (3.61%)

Overall (-4,886 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 13,712,182 -38
coreclr_tests.run.linux.arm.checked.mch 321,358,662 -3,940
libraries.pmi.linux.arm.checked.mch 49,904,152 -38
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 94,495,714 -776
realworld.run.linux.arm.checked.mch 13,599,632 -94
FullOpts (-4,886 bytes)
Collection Base size (bytes) Diff size (bytes)
benchmarks.run.linux.arm.checked.mch 13,399,606 -38
coreclr_tests.run.linux.arm.checked.mch 108,923,712 -3,940
libraries.pmi.linux.arm.checked.mch 49,797,928 -38
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch 84,465,944 -776
realworld.run.linux.arm.checked.mch 13,164,560 -94

Details here


Throughput diffs

Throughput diffs for linux/arm ran on windows/x86

Overall (+0.03%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.03%
libraries.crossgen2.linux.arm.checked.mch +0.03%
libraries.pmi.linux.arm.checked.mch +0.03%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%
MinOpts (+0.02% to +0.04%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.03%
libraries.crossgen2.linux.arm.checked.mch +0.02%
libraries.pmi.linux.arm.checked.mch +0.04%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%
FullOpts (+0.03% to +0.04%)
Collection PDIFF
benchmarks.run.linux.arm.checked.mch +0.03%
benchmarks.run_pgo.linux.arm.checked.mch +0.03%
benchmarks.run_tiered.linux.arm.checked.mch +0.03%
coreclr_tests.run.linux.arm.checked.mch +0.04%
libraries.crossgen2.linux.arm.checked.mch +0.03%
libraries.pmi.linux.arm.checked.mch +0.03%
libraries_tests.run.linux.arm.Release.mch +0.03%
libraries_tests_no_tiered_compilation.run.linux.arm.Release.mch +0.03%
realworld.run.linux.arm.checked.mch +0.03%

Details here


Throughput diffs for linux/arm64 ran on linux/x64

Overall (+0.00% to +0.01%)
Collection PDIFF
benchmarks.run_pgo.linux.arm64.checked.mch +0.01%
FullOpts (+0.00% to +0.01%)
Collection PDIFF
libraries_tests.run.linux.arm64.Release.mch +0.01%
benchmarks.run_pgo.linux.arm64.checked.mch +0.01%

Details here


@jkotas jkotas merged commit b7dcefe into dotnet:main Feb 6, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2024
@filipnavara filipnavara deleted the naot-managed-round branch June 5, 2025 07:33
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

arch-arm32 area-NativeAOT-coreclr community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NativeAOT] Rounding helpers use wrong rounding algorithm

7 participants