which LLVM transforms can optimize this code?

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

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

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

Hi Jun ,

Guess , the switch -dse will do the magic through opt and to know the analysis list ,use opt as shown below

opt -debug-pass=Structure file.ll

Thanks
~Umesh Kalappa