How to 'reloop' llvm code into ifs, whiles, fors?


I have a project to rewrite llvm output as OpenCL, It currently contains lots of conditional branches, whch become /labels / gotos in the output OpenCL.

What options are available to ‘reloop’ this to contain strictly ifs/fors/switches/breaks/whiles ?


There is the Böhm-Jacopini theorem, but that will probably be
inefficient, but necessary as a last resort for cases that can't
behandled otherwise.
The cbe ( seems to actually put some
loop constructs in the output, even though teh actual control flow is
done via goto, but the loop constructs there might help as a starting point.


You might try:

which claims to remove goto's without code replication.

   the method avoids problems of code replication