diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2022-12-20 21:31:44 -0500 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-12-21 03:04:59 -0500 |
| commit | a52dcdd3c5ebd3a1d5a0189ded830dadd253193c (patch) | |
| tree | 80bd063b2e762914a87bde8a393281ce0864a06a /src | |
| parent | 471f3c470fdeb00596ebd0d045a5b0dab737947d (diff) | |
| download | zig-a52dcdd3c5ebd3a1d5a0189ded830dadd253193c.tar.gz zig-a52dcdd3c5ebd3a1d5a0189ded830dadd253193c.zip | |
CBE: fix bitwise not
Closes #13911
Diffstat (limited to 'src')
| -rw-r--r-- | src/codegen/c.zig | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/codegen/c.zig b/src/codegen/c.zig index 2cd24f69b3..51b2f30cae 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -3591,6 +3591,10 @@ fn airOverflow(f: *Function, inst: Air.Inst.Index, operation: []const u8, info: } fn airNot(f: *Function, inst: Air.Inst.Index) !CValue { + const inst_ty = f.air.typeOfIndex(inst); + if (inst_ty.tag() != .bool) + return try airUnBuiltinCall(f, inst, "not", .Bits); + const ty_op = f.air.instructions.items(.data)[inst].ty_op; if (f.liveness.isUnused(inst)) { @@ -3602,11 +3606,10 @@ fn airNot(f: *Function, inst: Air.Inst.Index) !CValue { try reap(f, inst, &.{ty_op.operand}); const writer = f.object.writer(); - const inst_ty = f.air.typeOfIndex(inst); const local = try f.allocLocal(inst, inst_ty); try f.writeCValue(writer, local, .Other); try writer.writeAll(" = "); - try writer.writeByte(if (inst_ty.tag() == .bool) '!' else '~'); + try writer.writeByte('!'); try f.writeCValue(writer, op, .Other); try writer.writeAll(";\n"); |
