https://bugs.llvm.org/show_bug.cgi?id=45255

            Bug ID: 45255
           Summary: Loop with early continue does not produce same IR as
                    loop without
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedb...@nondot.org
          Reporter: matthew.arsena...@amd.com
                CC: llvm-bugs@lists.llvm.org

Created attachment 23260
  --> https://bugs.llvm.org/attachment.cgi?id=23260&action=edit
Testcase with early continue

This testcase has two versions of a program with a slightly different loop
structure.

The first testcase (extract.while.ll) looks like this:

while (I < N) {
  if (foo()) {
    ++I;
    continue;
  }

  bar();
  ++I;
}

The second version (extract.while.no.continue.ll looks like this:

while (I < N) {
  if (!foo()) {
    bar();
  }

  ++I;
}

I would expect these to optimize to the same IR, but they do not. The form with
the continue ends up codegenning to something worse, and ends up about 50%
slower on AMDGPU.

Note the attached IR has already gone through the optimizer once, and the
second form was rotated and has the preheader. I've been operating under the
assumption I should be able to just run -loop-rotate on the first form to get
equivalent IR as the second form.


The relevant part of the testcase is while.body.i/if.then320.i. if.then320.i is
the continue block in the first version.

I'm able to get opt -loop-rotate to rotate this loop by increasing
-rotation-max-header-size to at least 18, and hacking
profitableToRotateLoopExitingLatch to always return true

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to