aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authorRobin Voetter <robin@voetter.nl>2023-10-07 22:11:10 +0200
committerRobin Voetter <robin@voetter.nl>2023-10-15 14:00:01 +0200
commit0a3e566f57063c42146aa2d64481a7eb1361f96f (patch)
tree5d673f65f500bb26e0cc664b2d9ad7afb07ee4cd /src/codegen
parentc6c5fb40deaa104226581d79b3b9332315e11309 (diff)
downloadzig-0a3e566f57063c42146aa2d64481a7eb1361f96f.tar.gz
zig-0a3e566f57063c42146aa2d64481a7eb1361f96f.zip
spirv: make bitcasts between the same spirv type a no-op
Diffstat (limited to 'src/codegen')
-rw-r--r--src/codegen/spirv.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig
index 293ef5860b..82e172c0d7 100644
--- a/src/codegen/spirv.zig
+++ b/src/codegen/spirv.zig
@@ -2527,7 +2527,12 @@ const DeclGen = struct {
src_id: IdRef,
) !IdRef {
const mod = self.module;
+ const src_ty_ref = try self.resolveType(src_ty, .direct);
const dst_ty_ref = try self.resolveType(dst_ty, .direct);
+ if (src_ty_ref == dst_ty_ref) {
+ return src_id;
+ }
+
const result_id = self.spv.allocId();
// TODO: Some more cases are missing here
@@ -2811,7 +2816,8 @@ const DeclGen = struct {
fn airSliceElemPtr(self: *DeclGen, inst: Air.Inst.Index) !?IdRef {
const mod = self.module;
- const bin_op = self.air.instructions.items(.data)[inst].bin_op;
+ const ty_pl = self.air.instructions.items(.data)[inst].ty_pl;
+ const bin_op = self.air.extraData(Air.Bin, ty_pl.payload).data;
const slice_ty = self.typeOf(bin_op.lhs);
if (!slice_ty.isVolatilePtr(mod) and self.liveness.isUnused(inst)) return null;