aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/math.zig
AgeCommit message (Collapse)Author
2022-03-28x64: partially fix genImul, enable overflow testsJakub Konka
2022-03-27wasm: Enable overflow behavior testsLuuk de Gram
2022-03-23stage2: enable some passing array & vector testsWilliam Sengir
2022-03-19CBE: implement mod, divFloor, divTruncDaniele Cocca
2022-03-17CBE: enable more tests that are currently passingDaniele Cocca
2022-03-17Merge pull request #11192 from joachimschmidt557/stage2-armJoachim Schmidt
stage2 ARM: misc improvements
2022-03-16stage2: bit_not on u0 is always 0Mitchell Hashimoto
2022-03-16stage2 ARM: implement addwrap, subwrap, mulwrapjoachimschmidt557
2022-03-16stage2 ARM: fix shl for ints with bits < 32joachimschmidt557
2022-03-16stage2 ARM: fix bitwise negation of ints with bits < 32joachimschmidt557
2022-03-14Merge pull request #11143 from jmc-88/cbeAndrew Kelley
CBE: Implement popCount, byteSwap, bitReverse for ints <= 128 bits
2022-03-14CBE: split {clz,ctz,mod,popCount,byteSwap,bitReverse} by typeDaniele Cocca
This also surfaces the fact that clz, ctz and popCount didn't actually support 128 bit integers, despite what was claimed by 226fcd7c709ec664c5d883042cf7beb3026f66cb. This was partially hidden by the fact that the test code for popCount only exercised 128 bit integers in a comptime context. This commit duplicates that test case for runtime ints too.
2022-03-14Sema: improve lowering of stores to bitcasted vector pointersAndrew Kelley
Detect if we are storing an array operand to a bitcasted vector pointer. If so, we instead reach through the bitcasted pointer to the vector pointer, bitcast the array operand to a vector, and then lower this as a store of a vector value to a vector pointer. This generally results in better code, as well as working around an LLVM bug. See #11154
2022-03-13stage2 AArch64: enable mul for ints with <= 64 bitsjoachimschmidt557
2022-03-13stage2 AArch64: Implement bit shifting with immediate operandsjoachimschmidt557
2022-03-11CBE: implement clz, ctz for ints <= 128 bitsDaniele Cocca
2022-03-09wasm: Enable passing behavior testsLuuk de Gram
This also adds some float-related instructions to MIR/Emit
2022-03-05stage2 AArch64: add more slice supportjoachimschmidt557
* airSlice * airArrayToSlice * and initial support for airSlicePtr and co
2022-03-04stage2 ARM: generate less no-op branchesjoachimschmidt557
The checks detecting such no-op branches (essentially instructions that branch to the instruction immediately following the branch) were tightened to catch more of these occurrences.
2022-03-03behavior tests cleanup: promote math.zigAndrew Kelley
2022-02-26Sema: make `align(a) T` same as `align(a:0:N) T`Andrew Kelley
where `@sizeOf(T) == N`.
2022-02-13Implement f128 `@rem`Mateusz Radomski
2022-02-12disable NaN f80 behavior testsAndrew Kelley
Let's get all these other bug fixes in and figure out f80 NaN later. Looks like it's not working at comptime in master branch anyway.
2022-02-12LLVM backend: disable failing aarch64 behavior testAndrew Kelley
2022-02-07stage2: implement @sqrt for f{16,32,64}John Schmidt
Support for f128, comptime_float, and c_longdouble require improvements to compiler_rt and will implemented in a later PR. Some of the code in this commit could be made more generic, for instance `llvm.airSqrt` could probably be `llvm.airUnaryMath`, but let's cross that bridge when we get to it.
2022-02-06stage2: add more float arithmetic and f80 supportAndrew Kelley
AstGen: Fixed bug where f80 types in source were triggering illegal behavior. Value: handle f80 in floating point arithmetic functions. Value: implement floatRem and floatMod This commit introduces dependencies on compiler-rt that are not implemented. Those are a prerequisite to merging this branch.
2022-02-04Sema: check for NaNs in cmp (#10760)Mateusz Radomski
2022-02-01stage2: cmp_eq between untyped undefines values results in undef boolMitchell Hashimoto
2022-01-31std: correct rounding in parse_hex_float.zigMateusz Radomski
2022-01-30stage2: implement shl_exact and shr_exactAndrew Kelley
These produce an undefined value when one bits are shifted out. New AIR instruction: shr_exact.
2022-01-30Sema: fix comptime shl for fixed-width integersAndrew Kelley
2022-01-29Sema: improved comptime `%` syntaxAndrew Kelley
* comptime known 0 as a numerator returns comptime 0 independent of denominator. * negative numerator and denominator are allowed when the remainder is zero because that means the modulus would be also zero. * organize math behavior tests
2022-01-12stage2: implement `@ctz` and `@clz` including SIMDAndrew Kelley
AIR: * `array_elem_val` is now allowed to be used with a vector as the array type. * New instructions: splat, vector_init AstGen: * The splat ZIR instruction uses coerced_ty for the ResultLoc, avoiding an unnecessary `as` instruction, since the coercion will be performed in Sema. * Builtins that accept vectors now ignore the type parameter. Comment from this commit reproduced here: The accepted proposal #6835 tells us to remove the type parameter from these builtins. To stay source-compatible with stage1, we still observe the parameter here, but we do not encode it into the ZIR. To implement this proposal in stage2, only AstGen code will need to be changed. Sema: * `clz` and `ctz` ZIR instructions are now handled by the same function which accept AIR tag and comptime eval function pointer to differentiate. * `@typeInfo` for vectors is implemented. * `@splat` is implemented. It takes advantage of `Value.Tag.repeated` 😎 * `elemValue` is implemented for vectors, when the index is a scalar. Handling a vector index is still TODO. * Element-wise coercion is implemented for vectors. It could probably be optimized a bit, but it is at least complete & correct. * `Type.intInfo` supports vectors, returning int info for the element. * `Value.ctz` initial implementation. Needs work. * `Value.eql` is implemented for arrays and vectors. LLVM backend: * Implement vector support when lowering `array_elem_val`. * Implement vector support when lowering `ctz` and `clz`. * Implement `splat` and `vector_init`.
2021-12-21stage2: @shlWithOverflowRobin Voetter
2021-12-21stage2: @subWithOverflowRobin Voetter
2021-12-21stage2: @mulWithOverflowRobin Voetter
2021-12-21stage2: @addWithOverflowRobin Voetter
2021-10-24stage1/stage2: Simplify divTrunc implLemonBoy
According to the documentation, `divTrunc` is "Truncated division. Rounds toward zero". Lower it as a straightforward fdiv + trunc sequence to make it behave as expected with mixed positive/negative operands. Closes #10001
2021-10-21stage2: more division supportAndrew Kelley
AIR: * div is renamed to div_trunc. * Add div_float, div_floor, div_exact. - Implemented in Sema and LLVM codegen. C backend has a stub. Improvements to std.math.big.Int: * Add `eqZero` function to `Mutable`. * Fix incorrect results for `divFloor`. Compiler-rt: * Add muloti4 to the stage2 section.
2021-10-17stage2: bitNotRobin Voetter
2021-09-28stage2: implement `@clz` and `@ctz`Andrew Kelley
Also improve the LLVM backend to support lowering bigints to LLVM values. Moves over a bunch of math.zig test cases to the "passing for stage2" section.
2021-09-28stage2: more arithmetic supportAndrew Kelley
* AIR: add `mod` instruction for modulus division - Implement for LLVM backend * Sema: implement `@mod`, `@rem`, and `%`. * Sema: fix comptime switch evaluation * Sema: implement comptime shift left * Sema: fix the logic inside analyzeArithmetic to handle all the nuances between the different mathematical operations. - Implement comptime wrapping operations
2021-07-25ctz + clzAuguste Rame
2021-06-21std, src, doc, test: remove unused variablesJacob G-W
2021-05-08Merge remote-tracking branch 'origin/master' into stage2-whole-file-astgenAndrew Kelley
Conflicts: * doc/langref.html.in * lib/std/enums.zig * lib/std/fmt.zig * lib/std/hash/auto_hash.zig * lib/std/math.zig * lib/std/mem.zig * lib/std/meta.zig * test/behavior/alignof.zig * test/behavior/bitcast.zig * test/behavior/bugs/1421.zig * test/behavior/cast.zig * test/behavior/ptrcast.zig * test/behavior/type_info.zig * test/behavior/vector.zig Master branch added `try` to a bunch of testing function calls, and some lines also had changed how to refer to the native architecture and other `@import("builtin")` stuff.
2021-04-29move behavior tests from test/stage1/ to test/Andrew Kelley
And fix test cases to make them pass. This is in preparation for starting to pass behavior tests with self-hosted.