[LLVMdev] Extracting loop body
Dmitry N. Mikushin
maemarcus at gmail.com
Tue Apr 3 09:50:51 PDT 2012
Hi Paul,
FWIW, in KernelGen [1] we first use the loop extractor pass (which
extracts loops into functions) and afterwards substitute the loop
boundaries. If loop boundary values are small or fictive, optimization
passes will automatically remove the loop header for you.
So, replace loop boundary with 1, and it will be gone after opt
passes. This approach should be more safe & faster than manual
cleanup, which may involve dealing with things like phi nodes.
[1] http://kernelgen.org
- D.
2012/4/3 Redmond, Paul <paul.redmond at intel.com>:
> Hi,
>
>
>
> I’ve seen this question asked before but I haven’t seen an answer..
>
>
>
> I would like to extract the body of a (for) loop into a new function so I
> can do some transformations. The function ExtractCodeRegion seemed like a
> good candidate and I’ve got it to sort of work.
>
>
>
> My problem is that ExtractCodeRegion creates a function that still contains
> a loop. I was able to eliminate the loop by manually splitting the blocks of
> the original loop body after and before induction variable uses (hard code
> the instructions to split on)
>
>
>
> My question is, how can I reliably/more generally split the blocks of the
> loop body to avoid a loop in the extracted code region? Also, I should
> mention that in the presence of nested loops I would like to leave the inner
> loops intact.
>
>
>
> Has anyone done anything similar or perhaps there is something obvious I am
> missing?
>
>
>
> Thanks,
>
> paul
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list