hi, i am trying to optimize the below code, in one of my LLVM functions: .... store i32 96, i32* @XXX, align 4 ; (1) store i32 117, i32* @yyy, align 4 ; (2) store i32 31, i32* @XXX, align 4 ; (3) .... naturally, optimize passes should remove the line (1), because later line (3) overwrites the value of the same global variable XXX. i run this code via "opt" with option "-O3", and indeed line (1) was removed. but i want to do that in my code, without having to call "opt". however, after trying a lot of transforms (at FunctionPassManager level), line (1) is still there. so i am wondering which passes (in the list http://llvm.org/docs/Passes.html#transforms) can remove line (1) above? thanks, Jun
On Sat, Aug 11, 2012 at 7:42 PM, Jun Koi <junkoi2004 at gmail.com> wrote:> hi, > > i am trying to optimize the below code, in one of my LLVM functions: > > .... > store i32 96, i32* @XXX, align 4 ; (1) > store i32 117, i32* @yyy, align 4 ; (2) > store i32 31, i32* @XXX, align 4 ; (3) > .... > > naturally, optimize passes should remove the line (1), because later > line (3) overwrites the value of the same global variable XXX. > i run this code via "opt" with option "-O3", and indeed line (1) was removed. > > but i want to do that in my code, without having to call "opt". > however, after trying a lot of transforms (at FunctionPassManager > level), line (1) is still there. > > so i am wondering which passes (in the list > http://llvm.org/docs/Passes.html#transforms) can remove line (1) > above?i have some doubts here: - i only tried to optimize code with transforms (see the list http://llvm.org/docs/Passes.html#transforms). do i need to combine that with analysis passes (http://llvm.org/docs/Passes.html#analyses), or only transforms will do? if combination is necessary, how to combine? - i guess another reason that line (1) was not removed because i run the tranforms only once. do i need to run transforms in many rounds, and in different order to have better optimized code? many thanks, Jun
NAKAMURA Takumi
2012-Aug-11 14:06 UTC
[LLVMdev] which LLVM transforms can optimize this code?
In principle, transform passes are not responsible to inspect @yyy is not aliased to @XXX. I guess "opt -basicaa -{any-transform-passes}" would help you. You may also try "opt -{any-analysis-passes} -aa-eval}" Note, opt is the tool not for users but for developers. He does not invoke unspecified passes automatically. ...Takumi 2012/8/11 Jun Koi <junkoi2004 at gmail.com>:> On Sat, Aug 11, 2012 at 7:42 PM, Jun Koi <junkoi2004 at gmail.com> wrote: >> hi, >> >> i am trying to optimize the below code, in one of my LLVM functions: >> >> .... >> store i32 96, i32* @XXX, align 4 ; (1) >> store i32 117, i32* @yyy, align 4 ; (2) >> store i32 31, i32* @XXX, align 4 ; (3) >> .... >> >> naturally, optimize passes should remove the line (1), because later >> line (3) overwrites the value of the same global variable XXX. >> i run this code via "opt" with option "-O3", and indeed line (1) was removed. >> >> but i want to do that in my code, without having to call "opt". >> however, after trying a lot of transforms (at FunctionPassManager >> level), line (1) is still there. >> >> so i am wondering which passes (in the list >> http://llvm.org/docs/Passes.html#transforms) can remove line (1) >> above? > > i have some doubts here: > > - i only tried to optimize code with transforms (see the list > http://llvm.org/docs/Passes.html#transforms). do i need to combine > that with analysis passes (http://llvm.org/docs/Passes.html#analyses), > or only transforms will do? if combination is necessary, how to > combine? > > - i guess another reason that line (1) was not removed because i run > the tranforms only once. do i need to run transforms in many rounds, > and in different order to have better optimized code? > > many thanks, > Jun > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev