Port-amd64 archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: [patch] assembly clean-up: xor



In article <20150504180948.GA1741@localhost.localdomain>,
Joachim Henke  <free.software%gmx.com@localhost> wrote:
>-=-=-=-=-=-
>
>Browsing through the amd64 assembly code, I found that it could use a
>little bit of clean-up. E.g., many functions use 64 bit instructions,
>even in cases where it is not necessary.
>
>I prepared a patch set, which
> * uses shorter instruction encodings, if it does not effect speed
> * prefers instructions with lower delay
> * unifies some constructs between functions
>Altogether, it's not too intrusive, i.e. it's more an adjustment, not a
>rewrite.
>
>I attached the first patch, which is the simplest one (it's also the one
>which makes the most noise - with it applied, I think it's easier to
>review the following ones):
>
>All XOR operations for clearing a register are converted to 32 bit. This
>is sufficient because the upper 32 bits are set to 0 automatically. And
>it saves one byte (the REX.W prefix) in case of the first eight GPRs.
>
>You can see that compilers also prefer the 32 bit variant. As an
>example, none of the 64 bit ones are left in the kernel, when this patch
>is applied:
>
>~$ objdump -d /netbsd.old | \
>grep -Ec '[[:blank:]]xor[[:blank:]]+%r([a-s][ipx]|[89]|1[0-5]),%r\1'
>41
>~$ objdump -d /netbsd | \
>grep -Ec '[[:blank:]]xor[[:blank:]]+%r([a-s][ipx]|[89]|1[0-5]),%r\1'
>0
>
>(and the .text section of the kernel shrinks by 64 bytes)

Can you please file a PR with this? I am not sure if it is worth doing,
but at least it will not get lost in the meantime.

christos



Home | Main Index | Thread Index | Old Index