[LLVMdev] How to assign a constant to a register?
Alasdair.Grant at arm.com
Mon Oct 18 07:35:49 CDT 2010
> let me say that in general doing this is pointless. Due to SSA form,
> if %x is
> set to 5 you can't set it to something else later. Thus everywhere
> that you
> use %x you might as well just directly use 5 there instead.
But the cost of doing that might be greater than the costs
of keeping it in a register. Suppose the code was ORing a value
with 5 and the target only had OR-register and not OR-immediate.
You would expect local code generation to handle OR-immediate by
locally materialising the constant into a spare register.
But if the usage was in a loop it would be better (at the cost of
register pressure) to materialise 5 into a register outside of the
loop and use the register repeatedly in the loop.
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
More information about the LLVMdev