[LLVMdev] How to eliminate PHI nodes on pointer types?
Andrew Clinton
andrew at sidefx.com
Mon Aug 20 11:50:40 PDT 2012
Somewhere during optimization PHI nodes on pointer types (including
alloca instructions) are being introduced, and they persist through the
scalar replacement of aggregates pass and others. I can't seem to find
a combination of passes or transformations to get rid of them. Has
anyone had this problem before, and know a transformation to eliminate
it? My optimization passes rely on everything being in pure SSA form.
One more note, this particular optimization problem only seems to occur
in llvm 2.8, not 3.0 - though I can't say for sure whether it never
happens in 3.0.
Here's an example from the compiled code:
define private void @"vop_bindST at FFIFFI"(double* %news, double* %ss,
i32* %isSConnected, double* %newt, double* %tt, i32* %isTConnected)
nounwind alwaysinline {
entry:
%"reg2mem alloca point" = bitcast i32 0 to i32
%isSConnected1 = load i32* %isSConnected
%0 = icmp eq i32 %isSConnected1, 0
br i1 %0, label %false, label %true
true: ; preds = %entry
br label %end
false: ; preds = %entry
br label %end
end: ; preds = %false, %true
%phi.in.reg2mem.0 = phi double* [ @s, %false ], [ %ss, %true ]
%phi = load double* %phi.in.reg2mem.0
store double %phi, double* %news
%isTConnected4 = load i32* %isTConnected
%1 = icmp eq i32 %isTConnected4, 0
br i1 %1, label %false6, label %true5
true5: ; preds = %end
br label %end7
false6: ; preds = %end
br label %end7
end7: ; preds = %false6, %true5
%phi9.in.reg2mem.0 = phi double* [ @t, %false6 ], [ %tt, %true5 ]
%phi9 = load double* %phi9.in.reg2mem.0
store double %phi9, double* %newt
ret void
}
More information about the llvm-dev
mailing list