Repository navigation
Integer min and max are library methods: the MinMax trait's default bodies (part of #3483) - #3613
Merged
Merged
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #3483; the issue stays open.
a.min(b)anda.max(b)on an integer were a compiler intrinsic with a row inBuiltinSigs. They are now two default methods of a trait inlib/std/traits.with, implemented for the twelve integer types by one bodilessimplline each:Deleted: the integer dispatch and the name-based return type in
SemaCheck, the twoBuiltinSigsrows, and the integer branch of the LLVM arm. Floatmin/maxstay the built-in (llvm.minnum/maxnum: one instruction, with its NaN rule), and the C backend's arm is shared with floats and stays.No slowdown (the issue's condition): a 400-million-iteration loop of
.min(i).max(…)runs in 0.40 s built with main and 0.40 s built with this, same result.Test:
behav_3483_int_min_max_in_library: unsigned operands compare unsigned (#511), a literal takes the receiver's width, the type constantsi64.max/i8.minare still the constants, floatminis unchanged.Not gained:
minandmaxinside acomptime fn. They were refused before ("not comptime-evaluable yet") and still are; a trait cannot hold acomptime fntoday.Evidence at 21f87da: both compilers check the source; release build;
:unit-return-review,:ceremony-census,:self-audit,:native-compile-error-tests,:behavior-testsgreen; battery green;:release-checkssurvey: all targets green.