| author | |
| committer | |
| log | 6235afc63207bae564725adec202fc2e7a3ba930 |
| tree | 7b8ccfc2c6acf714f91671c49acff3a0d814b20d |
| parent | f20929bd8b6cd2b0af5edade9c27a5e002480d65 |
2 files changed, 21 insertions(+), 7 deletions(-)
src/stage1/codegen.cpp+3-7| ... | ... | @@ -4139,13 +4139,9 @@ static LLVMValueRef ir_render_binary_not(CodeGen *g, Stage1Air *executable, |
| 4139 | 4139 | static LLVMValueRef ir_gen_soft_f80_neg(CodeGen *g, ZigType *op_type, LLVMValueRef operand) { |
| 4140 | 4140 | uint32_t vector_len = op_type->id == ZigTypeIdVector ? op_type->data.vector.len : 0; |
| 4141 | 4141 | |
| 4142 | uint64_t buf[2] = {0, 0}; | |
| 4143 | if (g->is_big_endian != native_is_big_endian) { | |
| 4144 | buf[1] = 0x8000000000000000; | |
| 4145 | } else { | |
| 4146 | buf[1] = 0x8000; | |
| 4147 | } | |
| 4148 | LLVMValueRef sign_mask = LLVMConstIntOfArbitraryPrecision(LLVMInt128Type(), 2, buf); | |
| 4142 | LLVMTypeRef llvm_i80 = LLVMIntType(80); | |
| 4143 | LLVMValueRef sign_mask = LLVMConstInt(llvm_i80, 1, false); | |
| 4144 | sign_mask = LLVMConstShl(sign_mask, LLVMConstInt(llvm_i80, 79, false)); | |
| 4149 | 4145 | |
| 4150 | 4146 | LLVMValueRef result; |
| 4151 | 4147 | if (vector_len == 0) { |
test/behavior/floatop.zig+18| ... | ... | @@ -448,3 +448,21 @@ fn testTrunc() !void { |
| 448 | 448 | try expect(math.approxEqAbs(f32, @trunc(@as(f32, -0.4)), result[3], epsilon)); |
| 449 | 449 | } |
| 450 | 450 | } |
| 451 | ||
| 452 | test "negation" { | |
| 453 | if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO | |
| 454 | if (builtin.os.tag == .freebsd) return error.SkipZigTest; | |
| 455 | ||
| 456 | const S = struct { | |
| 457 | fn doTheTest() !void { | |
| 458 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { | |
| 459 | var a: T = 1; | |
| 460 | a = -a; | |
| 461 | try expect(a == -1); | |
| 462 | } | |
| 463 | } | |
| 464 | }; | |
| 465 | ||
| 466 | try S.doTheTest(); | |
| 467 | comptime try S.doTheTest(); | |
| 468 | } |