[LLVMdev] Assignment instruction.
Vikram S. Adve
vadve at cs.uiuc.edu
Mon Jul 12 08:53:02 PDT 2004
On Jul 12, 2004, at 7:24 AM, Tobias Nurmiranta wrote:
> Hi again,
> Which optimization/flag to "opt" should I use to optimize away these
The mem2reg pass (opt -mem2reg) converts allocas into SSA registers,
when legal, and inserts Phis as needed.
> In most cases it is more convenient for me to use SSA-registers,
> but for example if-statements and some others, it is nicer to use
Makes sense. Generally, values that cross merge points for branches
are more difficult because they may require Phis.
> Thanks for the advice.
> , Tobias
> On Thu, 17 Jun 2004, Chris Lattner wrote:
>> On Thu, 17 Jun 2004, Tobias Nurmiranta wrote:
>>> Thanks for the fast reply. I'll do as you suggested, and create my
>>> identity instructions with "add" for int's and "getelementptr" for
>> Another thing to point out is that this might only be happening
>> your front-end is attempting to generate SSA. In general, we don't
>> recommend that front-ends bother with generating code in SSA form:
>> needless effort and duplicates functionality in the optimizer.
>> In particular, consider making all user variables into stack memory
>> objects with the alloca instruction. If you do this, copies are
>> loads and stores to memory, which don't require any special handling:
>> int X = 4;
>> X = 5;
>> = X
>> %X = alloca int ;; in the entry bb for the function
>> store int 4, int* %X
>> store int 5, int* %X
>> ... = load int* %X
>> This makes it really easy for a front-end to generate code, doesn't
>> problems with copies, and the optimizer will construct SSA (and nice
>> code) for you. :)
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the llvm-dev