# x86_64: generate better constant memcpy code · gitcafe/zig

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

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

Visibility: public

Requested revision: 0c476191a4ad3514b2d10ba083ba2f86fee9b223

Requested commit: 0c476191a4ad3514b2d10ba083ba2f86fee9b223

Commit: 0c476191a4ad3514b2d10ba083ba2f86fee9b223

Tree: 6caf5db939c65417d0e48f67afb74a1d290a84bf

Author: mlugg

Committer: Jacob Young

## Message

```
x86_64: generate better constant memcpy code

`rep movsb` isn't usually a great idea here. This commit makes the logic
which tentatively existed in `genInlineMemcpy` apply in more cases, and
in particular applies it to the "new" backend logic. Put simply, all
copies of 128 bytes or fewer will now attempt this path first,
where---provided there is an SSE register and/or a general-purpose
register available---we will lower the operation using a sequence of 32,
16, 8, 4, 2, and 1 byte copy operations.

The feedback I got on this diff was "Push it to master and if it
miscomps I'll revert it" so don't blame me when it explodes

```

## Parents

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

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