I appreciate your suggestions, some follow-up questions though....
1) LLVM has the capabilities to do everything that you are trying to
re-implement.
2) Have you looked at the C backend? It recreates loops. It may not
create "for" loops but you can hack on it to do that.
3) The way you are converting out of SSA is wrong. You will suffer
from lost copies. You should look at using demotePHI(). see include/
llvm/Transforms/Utils/Local.h
I use LLVM 1.9 where I can't find demotePHI(). Is it a function available at later versions?
4) LLVM will compute your trip counts for you, use LoopInfo. You
need to be in SSA form to do this.
1) LLVM has the capabilities to do everything that you are trying to
re-implement.
2) Have you looked at the C backend? It recreates loops. It may not
create "for" loops but you can hack on it to do that.
I mean exactly this: look at the C backend in LLVM. It goes from LLVM IR
in SSA form to C code.
LLVM has everything you are trying to reimplement. You should spend some time looking through doxygen or the source code for examples.
3) The way you are converting out of SSA is wrong. You will suffer
from lost copies. You should look at using demotePHI(). see include/
llvm/Transforms/Utils/Local.h
I use LLVM 1.9 where I can't find demotePHI(). Is it a function available at later versions?
It is not in 1.9. You should really consider upgrading to 2.1 or 2.2 (its out in a week). 1.9 is almost 1.5 years old! demotePHI is in 2.1.
4) LLVM will compute your trip counts for you, use LoopInfo. You
need to be in SSA form to do this.