Roadmap / std.math functions the corpus kernels call
std.math.max on SIMD values: llvm.maxnum on floats, llvm.smax on signed integers
- Area
- std.math functions the corpus kernels call
- Kind
- construct
- Level
- L1 (modelled in Lean). Next: L2 needs a recorded GPU run (a conformance test, not a proof).
- Evidence present above the level
- None above the level.
- Reference
modular/modular@bbc13a71:Mojo/stdlib/std/math/math.mojo:3281- Quote
Performs elementwise maximum of x and y.
- Lean declarations
MojoProof.Sem.maxnumMojoProof.Sem.intMinMaxMojoProof.Sem.maxnum_of_not_nanMojoProof.Sem.maxnum_nanEq
- Corpus files
44 kernel files (
.ll) in the corpus.- Tests
MojoProofTest.EvalMojoProofTest.SymSelectMojoProofTest.Rule
- Upstream issue
- None filed.
- Depends on
- llvm-ir/intrinsic-fminmax, llvm-ir/intrinsic-minmax
Rule
max on two SIMD values (math.mojo:3280) asserts a numeric or boolean type (lines 3300-3302) and is the MLIR operation pop.max (line 3304). The corpus IR has llvm.maxnum on float32 scalars and vectors (the 34 layer-norm files) and llvm.smax.i64 (the layer-norm files, the 10 GEMM files without contraction and 35 of the 49 GEMM files). The contract on floats is LangRef's for llvm.maxnum, as MojoProof.Sem.maxnum states it: IEEE 754-2019 maximumNumber of the operands, except that when an operand is a signaling NaN the result may instead be a NaN. That choice and the bits of any NaN are the oracle's (docs/TRUST.md T7). On integers it is exact (MojoProof.Sem.intMinMax).
In scope
float32 maxnum and i64 smax, as the corpus IR calls them.
Out of scope
Which source call produced each intrinsic call. pop.max is lowered by the compiler, which we cannot see, and the IR does not say whether the call was std.math.max or another max. Boolean and unsigned max, and the variadic overload (math.mojo:3308).
Open
L2 needs a recorded GPU run of a test of the construct; there is none.