diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2025-02-01 14:32:43 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-01 14:32:43 -0800 |
| commit | 963651bbf292b21017cac9e977a933b5e2a8c671 (patch) | |
| tree | 4b2dc8071e8ebe522f24d8dec8584582b25261d5 /src/codegen/spirv.zig | |
| parent | cdc9d65b0db3e988ae0f4006e05c178312518bfb (diff) | |
| parent | 4c5abe5ac664a7214d822b09703682a5cac6891c (diff) | |
| download | zig-963651bbf292b21017cac9e977a933b5e2a8c671.tar.gz zig-963651bbf292b21017cac9e977a933b5e2a8c671.zip | |
Merge pull request #22672 from jacobly0/x86_64-rewrite
x86_64: rewrite float conversions
Diffstat (limited to 'src/codegen/spirv.zig')
| -rw-r--r-- | src/codegen/spirv.zig | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index e9322a9d70..e1baf20156 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -3449,10 +3449,8 @@ const NavGen = struct { .bitcast => try self.airBitCast(inst), .intcast, .trunc => try self.airIntCast(inst), - .int_from_ptr => try self.airIntFromPtr(inst), .float_from_int => try self.airFloatFromInt(inst), .int_from_float => try self.airIntFromFloat(inst), - .int_from_bool => try self.airIntFromBool(inst), .fpext, .fptrunc => try self.airFloatCast(inst), .not => try self.airNot(inst), @@ -4706,9 +4704,14 @@ const NavGen = struct { fn airBitCast(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; - const operand_id = try self.resolve(ty_op.operand); const operand_ty = self.typeOf(ty_op.operand); const result_ty = self.typeOfIndex(inst); + if (operand_ty.toIntern() == .bool_type) { + const operand = try self.temporary(ty_op.operand); + const result = try self.intFromBool(operand); + return try result.materialize(self); + } + const operand_id = try self.resolve(ty_op.operand); return try self.bitCast(result_ty, operand_ty, operand_id); } @@ -4749,12 +4752,6 @@ const NavGen = struct { return result_id; } - fn airIntFromPtr(self: *NavGen, inst: Air.Inst.Index) !?IdRef { - const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - const operand_id = try self.resolve(un_op); - return try self.intFromPtr(operand_id); - } - fn airFloatFromInt(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; const operand_ty = self.typeOf(ty_op.operand); @@ -4808,13 +4805,6 @@ const NavGen = struct { return result_id; } - fn airIntFromBool(self: *NavGen, inst: Air.Inst.Index) !?IdRef { - const un_op = self.air.instructions.items(.data)[@intFromEnum(inst)].un_op; - const operand = try self.temporary(un_op); - const result = try self.intFromBool(operand); - return try result.materialize(self); - } - fn airFloatCast(self: *NavGen, inst: Air.Inst.Index) !?IdRef { const ty_op = self.air.instructions.items(.data)[@intFromEnum(inst)].ty_op; const operand_id = try self.resolve(ty_op.operand); |
