diff options
| author | David Rubin <david@vortan.dev> | 2025-08-28 07:46:12 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-28 15:46:12 +0100 |
| commit | 73a0b5441be3dc6adb666ca672f3c4f7972cf73e (patch) | |
| tree | aa88a8e771daaf3ac83aa8909a5d29f444c80299 /test/behavior/floatop.zig | |
| parent | a31950aa578824e0933b49109f6ac55c84979b6d (diff) | |
| download | zig-73a0b5441be3dc6adb666ca672f3c4f7972cf73e.tar.gz zig-73a0b5441be3dc6adb666ca672f3c4f7972cf73e.zip | |
AstGen: forward result type through unary float builtins
Uses a new `float_op_result_ty` ZIR instruction tag.
Diffstat (limited to 'test/behavior/floatop.zig')
| -rw-r--r-- | test/behavior/floatop.zig | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/behavior/floatop.zig b/test/behavior/floatop.zig index 3f664473d1..418e8f2a5c 100644 --- a/test/behavior/floatop.zig +++ b/test/behavior/floatop.zig @@ -1737,3 +1737,31 @@ test "comptime calls are only memoized when float arguments are bit-for-bit equa try comptime testMemoization(); try comptime testVectorMemoization(@Vector(4, f32)); } + +test "result location forwarded through unary float builtins" { + if (builtin.zig_backend == .stage2_wasm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64 and builtin.target.ofmt != .elf and builtin.target.ofmt != .macho) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_riscv64) return error.SkipZigTest; + if (builtin.zig_backend == .stage2_spirv) return error.SkipZigTest; + + const S = struct { + var x: u32 = 10; + }; + + var y: f64 = 0.0; + y = @sqrt(@floatFromInt(S.x)); + y = @sin(@floatFromInt(S.x)); + y = @cos(@floatFromInt(S.x)); + y = @tan(@floatFromInt(S.x)); + y = @exp(@floatFromInt(S.x)); + y = @exp2(@floatFromInt(S.x)); + y = @log(@floatFromInt(S.x)); + y = @log2(@floatFromInt(S.x)); + y = @log10(@floatFromInt(S.x)); + y = @floor(@floatFromInt(S.x)); + y = @ceil(@floatFromInt(S.x)); + y = @trunc(@floatFromInt(S.x)); + y = @round(@floatFromInt(S.x)); +} |
