Hi all, is there a pass to get rid of phi-instructions in a function? There's no loop involved. I have a function approx. like this: void @func() { entry: … bb1: … bb2: … %tmp100 = phi i32 [ 0, bb1 ], [ 1, bb2 ] … %tmp101 = getelementptr …, %tmp100 tail call void @anotherfunc(…, %tmp101) ret void } I would like it to rather be something like this: void @func() { entry: … bb1: ... %tmp90 = getelementptr …, %tmp89 tail call void @anotherfunc(%tmp90) ret void bb2: … %tmp101 = getelementptr …, %tmp100 tail call void @anotherfunc(%tmp101) ret void } Best regards, Teemu -- Teemu Rinta-aho Tel: +358 9 299 3078 Ericsson Research Mobile: +358 40 562 3066 Oy L M Ericsson Ab Fax: +358 9 299 3535 02420 Jorvas, Finland E-mail: teemu.rinta-aho at nomadiclab.com
On Tue, Aug 30, 2011 at 9:12 AM, Teemu Rinta-aho <teemu.rinta-aho at nomadiclab.com> wrote:> Hi all, > > is there a pass to get rid of phi-instructions in a function? There's no loop involved.reg2mem.> I have a function approx. like this: > > void @func() { > entry: > … > bb1: > … > bb2: > … > %tmp100 = phi i32 [ 0, bb1 ], [ 1, bb2 ] … > %tmp101 = getelementptr …, %tmp100 > tail call void @anotherfunc(…, %tmp101) > ret void > } > > I would like it to rather be something like this: > > void @func() { > entry: > … > bb1: > ... > %tmp90 = getelementptr …, %tmp89 > tail call void @anotherfunc(%tmp90) > ret void > bb2: > … > %tmp101 = getelementptr …, %tmp100 > tail call void @anotherfunc(%tmp101) > ret void > }reg2mem won't do quite this transformation... not sure exactly what you need. -Eli
On 30.8.2011, at 19.19, Eli Friedman wrote:> reg2mem won't do quite this transformation... not sure exactly what you need.I need to get rid of phis. This code is compiled from C++ and for some functions there are no phis, but multiple call instructions. I am targeting hardware in the end, and the next tool reading the IR does not like phis when it's generating VHDL. My questions may be somewhat silly from the viewpoint of software compilation for a CPU. Thanks. Teemu