aboutsummaryrefslogtreecommitdiff
path: root/test/behavior/math.zig
AgeCommit message (Collapse)Author
2025-10-02Coff2: create a new linker from scratchJacob Young
2025-09-20coerce vectors to arrays rather than inline forAndrew Kelley
2025-09-20compiler: require comptime vector indexesAndrew Kelley
2025-09-18test: disable some vector ctz/clz behavior tests on LoongArch with LSXAlex Rønne Petersen
https://github.com/llvm/llvm-project/issues/159529
2025-07-31Merge pull request #24537 from IOKG04/some-documentation-updates-0Matthew Lugg
some small langref changes
2025-07-28aarch64: implement scalar `@mod`Jacob Young
2025-07-28Merge branch 'ziglang:master' into some-documentation-updates-0Rue
2025-07-22aarch64: add new from scratch self-hosted backendJacob Young
2025-07-22`@rem()` and `@mod()` take `denominator != 0`, not just `denominator > 0`IOKG04
https://github.com/ziglang/zig/issues/23635 I also added tests for `@rem()` with `denominator < 0` cause there were none before I hope I added them in the correct place, if not I can change it ofc
2025-06-28riscv64: skip failing testsBingwu Zhang
2025-06-19x86_64: increase passing test coverage on windowsJacob Young
Now that codegen has no references to linker state this is much easier. Closes #24153
2025-06-16rename spirv backend nameAli Cheraghi
`stage2_spirv64` -> `stage2_spirv`
2025-06-06Compilation: enable the x86_64 backend by default for debug buildsJacob Young
Closes #22257
2025-06-05std.Target: Introduce Cpu convenience functions for feature tests.Alex Rønne Petersen
Before: * std.Target.arm.featureSetHas(target.cpu.features, .has_v7) * std.Target.x86.featureSetHasAny(target.cpu.features, .{ .sse, .avx, .cmov }) * std.Target.wasm.featureSetHasAll(target.cpu.features, .{ .atomics, .bulk_memory }) After: * target.cpu.has(.arm, .has_v7) * target.cpu.hasAny(.x86, &.{ .sse, .avx, .cmov }) * target.cpu.hasAll(.wasm, &.{ .atomics, .bulk_memory })
2025-06-02x86_64: implement integer `@divFloor` and `@mod`Jacob Young
Closes #24039
2025-06-01Legalize: implement scalarization of overflow intrinsicsJacob Young
2025-05-31Legalize: implement scalarization of binary operationsJacob Young
2025-05-31Legalize: implement scalarization of unary operationsJacob Young
2025-04-11Merge pull request #23061 from pavelverigo/stage2-wasm-miscAndrew Kelley
stage2-wasm: multiple fixes
2025-04-11Merge pull request #23355 from jacobly0/x86_64-rewriteJacob Young
x86_64: start rewriting overflow operations
2025-04-11test: Disable a bunch of vector behavior tests for hexagon.Alex Rønne Petersen
Most of the failures are: * https://github.com/llvm/llvm-project/issues/118879 * https://github.com/llvm/llvm-project/issues/134659 But some are also miscompilations leading to wrong results. I'm not going to investigate the latter further until all the backend crashes have been resolved.
2025-04-09x86_64: rewrite scalar `@mulWithOverflow`Jacob Young
Closes #19607
2025-03-24stage2-wasm: clz fixPavel Verigo
2025-03-16Sema: rewrite comptime arithmeticmlugg
This commit reworks how Sema handles arithmetic on comptime-known values, fixing many bugs in the process. The general pattern is that arithmetic on comptime-known values is now handled by the new namespace `Sema.arith`. Functions handling comptime arithmetic no longer live on `Value`; this is because some of them can emit compile errors, so some *can't* go on `Value`. Only semantic analysis should really be doing arithmetic on `Value`s anyway, so it makes sense for it to integrate more tightly with `Sema`. This commit also implements more coherent rules surrounding how `undefined` interacts with comptime and mixed-comptime-runtime arithmetic. The rules are as follows. * If an operation cannot trigger Illegal Behavior, and any operand is `undefined`, the result is `undefined`. This includes operations like `0 *| undef`, where the LHS logically *could* be used to determine a defined result. This is partly to simplify the language, but mostly to permit codegen backends to represent `undefined` values as completely invalid states. * If an operation *can* trigger Illegal Behvaior, and any operand is `undefined`, then Illegal Behavior results. This occurs even if the operand in question isn't the one that "decides" illegal behavior; for instance, `undef / 1` is undefined. This is for the same reasons as described above. * An operation which would trigger Illegal Behavior, when evaluated at comptime, instead triggers a compile error. Additionally, if one operand is comptime-known undef, such that the other (runtime-known) operand isn't needed to determine that Illegal Behavior would occur, the compile error is triggered. * The only situation in which an operation with one comptime-known operand has a comptime-known result is if that operand is undefined, in which case the result is either undefined or a compile error per the above rules. This could potentially be loosened in future (for instance, `0 * rt` could be comptime-known 0 with a runtime assertion that `rt` is not undefined), but at least for now, defining it more conservatively simplifies the language and allows us to easily change this in future if desired. This commit fixes many bugs regarding the handling of `undefined`, particularly in vectors. Along with a collection of smaller tests, two very large test cases are added to check arithmetic on `undefined`. The operations which have been rewritten in this PR are: * `+`, `+%`, `+|`, `@addWithOverflow` * `-`, `-%`, `-|`, `@subWithOverflow` * `*`, `*%`, `*|`, `@mulWithOverflow` * `/`, `@divFloor`, `@divTrunc`, `@divExact` * `%`, `@rem`, `@mod` Other arithmetic operations are currently unchanged. Resolves: #22743 Resolves: #22745 Resolves: #22748 Resolves: #22749 Resolves: #22914
2025-02-24test: skip failing tests with spirv-vulkanAli Cheraghi
2025-02-17std.Target: Remove functions that just wrap component functions.Alex Rønne Petersen
Functions like isMinGW() and isGnuLibC() have a good reason to exist: They look at multiple components of the target. But functions like isWasm(), isDarwin(), isGnu(), etc only exist to save 4-8 characters. I don't think this is a good enough reason to keep them, especially given that: * It's not immediately obvious to a reader whether target.isDarwin() means the same thing as target.os.tag.isDarwin() precisely because isMinGW() and similar functions *do* look at multiple components. * It's not clear where we would draw the line. The logical conclusion before this commit would be to also wrap Arch.isX86(), Os.Tag.isSolarish(), Abi.isOpenHarmony(), etc... this obviously quickly gets out of hand. * It's nice to just have a single correct way of doing something.
2025-02-15x86_64: rewrite scalar and vector int `@rem`Jacob Young
2025-02-10cbe: fix ub triggered by mulw overflowing the promoted typeJacob Young
Closes #21914
2025-01-16x86_64: pass more behavior testsJacob Young
2025-01-16x86_64: implement switch jump tablesJacob Young
2025-01-16x86_64: implement clz and notJacob Young
2024-11-03std.Target: Replace isARM() with isArmOrThumb() and rename it to isArm().Alex Rønne Petersen
The old isARM() function was a portability trap. With the name it had, it seemed like the obviously correct function to use, but it didn't include Thumb. In the vast majority of cases where someone wants to ask "is the target Arm?", Thumb *should* be included. There are exactly 3 cases in the codebase where we do actually need to exclude Thumb, although one of those is in Aro and mirrors a check in Clang that is itself likely a bug. These rare cases can just add an extra isThumb() check.
2024-10-13spirv: skip range switch testsRobin Voetter
This is not yet implemented
2024-10-08stage2-wasm: airRem + airMod for floatsPavel Verigo
2024-09-17Sema: clean up cmpNumericmlugg
There is one minor language change here, which is that comparisons of the form `comptime_inf < runtime_f32` have their results comptime-known. This is consistent with comparisons against comptime NaN for instance, which are always comptime known. A corresponding behavior test is added. This fixes a bug with int comparison elision which my previous commit somehow triggered. `Sema.compareIntsOnlyPossibleResult` is much cleaner now!
2024-09-12test: Re-enable a bunch of behavior tests with LLVM.Alex Rønne Petersen
Closes #10627. Closes #12013. Closes #18034.
2024-09-10test: Skip some floating point tests that fail on `arm-linux-(gnu,musl)eabi`.Alex Rønne Petersen
https://github.com/ziglang/zig/issues/21234
2024-08-28std: update `std.builtin.Type` fields to follow naming conventionsmlugg
The compiler actually doesn't need any functional changes for this: Sema does reification based on the tag indices of `std.builtin.Type` already! So, no zig1.wasm update is necessary. This change is necessary to disallow name clashes between fields and decls on a type, which is a prerequisite of #9938.
2024-07-26riscv: enable passing testsDavid Rubin
2024-07-26riscv: implement `@clz`David Rubin
2024-07-26riscv: implement more operatorsDavid Rubin
we can run `std.debug.print` now, with both run-time strings and integers!
2024-07-20disable failing tests on stage2 backendsPavel Verigo
2024-07-20stage2-wasm: @mulWithOverflow fixes + 128 bit signedPavel Verigo
2024-07-18stage2-wasm: improve @shlWithOverflow for <= 128 bitsPavel Verigo
Additionally fixed a bug for shr on signed big ints
2024-07-18stage2-wasm: enhance add/subWithOverflowPavel Verigo
Added behavior tests to verify implementation
2024-07-14riscv: truncate `airStructFieldVal` resultDavid Rubin
2024-07-02stage2-wasm: not op for <= 128 bits intsPavel Verigo
2024-06-22stage2-wasm: fix div and remPavel Verigo
2024-06-13riscv: rewrite "binOp"David Rubin
Reorganize how the binOp and genBinOp functions work. I've spent quite a while here reading exactly through the spec and so many tests are enabled because of several critical issues the old design had. There are some regressions that will take a long time to figure out individually so I will ignore them for now, and pray they get fixed by themselves. When we're closer to 100% passing is when I will start diving into them one-by-one.
2024-06-13riscv: integer + float `@abs`David Rubin