Skip to content

Use constants in registers to avoid immediate constants in instructions #11716

@cooperp

Description

@cooperp
Bugzilla Link 11344
Version unspecified
OS All
CC @asl

Extended Description

In MultiSource/.../oggenc vorbis_encode_ctl the following sequence of instructions is generated

    testq	%rbx, %rbx
jne	LBB11_38
movq	$0, 5568(%rax)
movq	$0, 5592(%rax)
movq	$0, 5600(%rax)
pxor	%xmm0, %xmm0
xorl	%ecx, %ecx
xorl	%edx, %edx
jmp	LBB11_43

I think for the $0 in the moves we should use the knowledge that %rbx must already be 0 since the condition jumped on nonzero. We can then use rbi in the instructions to shorten the encoding. More generally, we should use any knowledge we have of constants in registers from previous blocks to avoid regenerating them in current blocks.

An alternative to using %rbx here would have been to see that any the end of the block both %ecx and %edx were set to 0. Had those been 64-bit registers we could have used either on instead of $0 had we moved the xor sooner

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzilla

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions