| author | |
| committer | |
| log | 06ab4f702e29d173919ab8e4471467e5bab05af5 |
| tree | 846b8144511787bdbfd27b7313225ae13442d44c |
| parent | 2322d45d80a88730b356b6a2b0101bcffb5a0afd |
2 files changed, 9 insertions(+), 1 deletions(-)
src/codegen/llvm/FuncGen.zig+1-1| ... | ... | @@ -5127,7 +5127,7 @@ fn airMemset(self: *FuncGen, inst: Air.Inst.Index, safety: bool) Allocator.Error |
| 5127 | 5127 | const value = try self.resolveInst(bin_op.rhs); |
| 5128 | 5128 | const elem_abi_size = elem_ty.abiSize(zcu); |
| 5129 | 5129 | |
| 5130 | if (elem_abi_size == 1) { | |
| 5130 | if (elem_abi_size == 1 and elem_ty.bitSize(zcu) == 8) { | |
| 5131 | 5131 | // In this case we can take advantage of LLVM's intrinsic. |
| 5132 | 5132 | const fill_byte = try self.bitCast(value, elem_ty, Type.u8); |
| 5133 | 5133 | const len = try self.sliceOrArrayLenInBytes(dest_slice, ptr_ty); |
test/behavior/memset.zig+8| ... | ... | @@ -190,3 +190,11 @@ test "@memset a global array" { |
| 190 | 190 | @memset(&S.buf, S.buf[0] + 333); |
| 191 | 191 | try expect(S.buf[0] == 789); |
| 192 | 192 | } |
| 193 | ||
| 194 | test "@memset array of booleans" { | |
| 195 | const S = struct { | |
| 196 | var x: bool = false; | |
| 197 | var y: [1]bool = undefined; | |
| 198 | }; | |
| 199 | @memset(&S.y, S.x); | |
| 200 | } |