[LLVMdev] An LLVM pass that does loop header fission?

Paul Vario paul.paul.mit at gmail.com
Mon Jun 2 14:19:35 PDT 2014


Hi Fellows,

   In the following C code,

          for (int t = 0; t < N; ++t) { // loop A
             int result = 0;
             for (int i = 0; i < M; ++i) { // loop B
                ... ... ...
             }
          }

   clang puts "int result = 0" in the loop B's header (along with int i =
0). But
what I need is "int result = 0" residing in the preheader of the loop
(I.e., in
a separated BB from where "int i = 0" is at). Is there an LLVM pass that
can
force that to happen always?



                                                 __________
                           \                    |
                            \                  \|/
                            \/
                            %result = phi i32 [%val1, %BB1],[%val2, %BB2]
                            %i = phi i32 [%inc, %loopB.inc], [0,
%loopB.preheader]
                            %cmp = icmp slt i32 %i, M
                            br i1 %cmp ...
                               \
                                \
                                \/

into

                                                 __________
                           \                    |
                            \                  \|/
                            \/
                            %result = phi i32 [%val1, %BB1],[%val2, %BB2]
                                            |
                                            |
                                           \|/
                            %i = phi i32 [%inc, %loopB.inc], [0,
%loopB.preheader]
                            %cmp = icmp slt i32 %i, M
                            br i1 %cmp ...
                               \
                                \
                                \/


Best Regards,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140602/7efa8c45/attachment.html>


More information about the llvm-dev mailing list