<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Optimizer fails to unroll the Coroutine-Loop."
   href="https://bugs.llvm.org/show_bug.cgi?id=34293">34293</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Optimizer fails to unroll the Coroutine-Loop.
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Loop Optimizer
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>peetlugen19@yandex.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=19033" name="attach_19033" title="testcase">attachment 19033</a> <a href="attachment.cgi?id=19033&action=edit" title="testcase">[details]</a></span>
testcase

Test case: <a href="https://godbolt.org/g/esjnb2">https://godbolt.org/g/esjnb2</a>

I've also attached the test-case as an attachment.

LLVM-IR:

define void @printEquivalent()() local_unnamed_addr #0 !dbg !684 {
  %1 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8],
[3 x i8]* @.str, i64 0, i64 0), i32 1), !dbg !685
  %2 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8],
[3 x i8]* @.str, i64 0, i64 0), i32 3), !dbg !686
  ret void, !dbg !687
}

declare i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr #1

define i32 @main() local_unnamed_addr #2 personality i8* bitcast (i32 (...)*
@__gxx_personality_v0 to i8*) !dbg !688 {
  br label %1, !dbg !693

; <label>:1:                                      ; preds = %0, %5
  %2 = phi i2 [ 0, %0 ], [ %7, %5 ]
  switch i2 %2, label %4 [
    i2 0, label %5
    i2 1, label %3
    i2 -2, label %9
  ]

; <label>:3:                                      ; preds = %1
  br label %5, !dbg !826

; <label>:4:                                      ; preds = %1
  unreachable, !dbg !824

; <label>:5:                                      ; preds = %1, %3
  %6 = phi i32 [ 3, %3 ], [ 1, %1 ]
  %7 = phi i2 [ -2, %3 ], [ 1, %1 ]
  %8 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8],
[3 x i8]* @.str, i64 0, i64 0), i32 %6), !dbg !828
  br label %1, !dbg !693, !llvm.loop !830

; <label>:9:                                      ; preds = %1
  ret i32 0, !dbg !832
}


Issue:

The optimizer could have optimized the couroutine into something more like the
two sequential calls to printf. Instead, it isn't able to unroll the
"couroutine-loop".</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>