# stage1: avoid wasting padding with IR instruction tag · gitcafe/zig

[View on GitCafe](https://git.cafe/gitcafe/zig/commit/40764650afd47f2ca2d191ed4d910f680702e014)

Repository: [gitcafe/zig](https://git.cafe/gitcafe/zig)

Visibility: public

Requested revision: 40764650afd47f2ca2d191ed4d910f680702e014

Requested commit: 40764650afd47f2ca2d191ed4d910f680702e014

Commit: 40764650afd47f2ca2d191ed4d910f680702e014

Tree: 0dd5d4a704d74b4d6515f18bfd070aeadf50b4e9

Author: Andrew Kelley

Committer: Andrew Kelley

## Message

```
stage1: avoid wasting padding with IR instruction tag

For stage1 ZIR instructions and stage1 AIR instructions, the instruction
op code was taking up 8 bytes due to padding even though it only needed
1 byte. This commit reduces the ref_count field from uint32_t to
uint16_t because the code only really cares if instructions are
referenced at all, not how many times they are referenced. With the
ref_count field reduced to uint16_t the uint8_t op code is now placed in
the freed up space.

Empirically, this saves 382 MiB of peak RAM usage when building the
self-hosted compiler, which is a reduction of 5%. Consequently this
resulted in a 3% reduction of cache-misses when building the self-hosted
compiler.

This was @SpexGuy's idea, committed by me because we tested it on my
computer.

```

## Parents

- [b9e896d7b076e59d6f6dd9b0bad9697875d1f6e4](https://git.cafe/gitcafe/zig/commit/b9e896d7b076e59d6f6dd9b0bad9697875d1f6e4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zig/tree/40764650afd47f2ca2d191ed4d910f680702e014?format=markdown)
