| ... | @@ -1895,13 +1895,17 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { | ... | @@ -1895,13 +1895,17 @@ fn derivePtr(cg: *CodeGen, derivation: Value.PointerDeriveStep) !Id { |
| 1895 | depth += 1; | 1895 | depth += 1; |
| 1896 | } else break; | 1896 | } else break; |
| 1897 | } | 1897 | } |
| 1898 | if (depth > 0 and cur.toIntern() == dst_child.toIntern()) { | 1898 | if (cur.toIntern() == dst_child.toIntern()) { |
| 1899 | const scratch_top = cg.id_scratch.items.len; | 1899 | if (depth != 0) { |
| 1900 | defer cg.id_scratch.shrinkRetainingCapacity(scratch_top); | 1900 | const scratch_top = cg.id_scratch.items.len; |
| 1901 | const zero = try cg.constInt(.u32, 0); | 1901 | defer cg.id_scratch.shrinkRetainingCapacity(scratch_top); |
| 1902 | const ids = try cg.id_scratch.addManyAsSlice(gpa, depth); | 1902 | const zero = try cg.constInt(.u32, 0); |
| 1903 | @memset(ids, zero); | 1903 | const ids = try cg.id_scratch.addManyAsSlice(gpa, depth); |
| 1904 | return cg.accessChainId(result_ty_id, parent_ptr_id, ids); | 1904 | @memset(ids, zero); |
| | 1905 | return cg.accessChainId(result_ty_id, parent_ptr_id, ids); |
| | 1906 | } else { |
| | 1907 | return parent_ptr_id; |
| | 1908 | } |
| 1905 | } | 1909 | } |
| 1906 | if (target.os.tag == .opencl) { | 1910 | if (target.os.tag == .opencl) { |
| 1907 | const result_ptr_id = cg.allocId(); | 1911 | const result_ptr_id = cg.allocId(); |