diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-06-30 00:02:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-06-30 00:02:00 -0700 |
| commit | 6bc6e47b1582a4538078c8f4e9b3dae386854d07 (patch) | |
| tree | 3919cd49e8cfe2772c4028f0b056f47040651494 /src/Sema.zig | |
| parent | 54454fd0102af8b25dbc85751d37fd265380d920 (diff) | |
| download | zig-6bc6e47b1582a4538078c8f4e9b3dae386854d07.tar.gz zig-6bc6e47b1582a4538078c8f4e9b3dae386854d07.zip | |
stage2: lower float negation explicitly
Rather than lowering float negation as `0.0 - x`.
* Add AIR instruction for float negation.
* Add compiler-rt functions for f128, f80 negation
closes #11853
Diffstat (limited to 'src/Sema.zig')
| -rw-r--r-- | src/Sema.zig | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/Sema.zig b/src/Sema.zig index fdf3810d4a..a071c97df3 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -10070,12 +10070,14 @@ fn zirNegate(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air. } if (rhs_scalar_ty.isAnyFloat()) { - // We handle comptime negation here to ensure negative zero is represented in the bits. + // We handle float negation here to ensure negative zero is represented in the bits. if (try sema.resolveMaybeUndefVal(block, rhs_src, rhs)) |rhs_val| { if (rhs_val.isUndef()) return sema.addConstUndef(rhs_ty); const target = sema.mod.getTarget(); return sema.addConstant(rhs_ty, try rhs_val.floatNeg(rhs_ty, sema.arena, target)); } + try sema.requireRuntimeBlock(block, rhs_src); + return block.addUnOp(.neg, rhs); } const lhs = if (rhs_ty.zigTypeTag() == .Vector) |
