[LLVMdev] How to assign a constant to a register?
Duncan Sands
baldrick at free.fr
Mon Oct 18 05:18:48 PDT 2010
Hi,
> Other than:
> %x = add i32 5,0 ; suppose I want to assign 5 to %x
>
> is there any other way? Something like x86's mov instruction
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. A common situation
is that you have a register %x, and due to performing optimizations you discover
that in fact %x will always have the value 5. You can use RAUW (aka the
replaceAllUsesWith method) to replace %x with 5 everywhere.
Ciao,
Duncan.
More information about the llvm-dev
mailing list