<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 - SCEV: Assertion `L && L->getHeader() == P->getParent()' failed in getRangeForUnknownRecurrence"
   href="https://bugs.llvm.org/show_bug.cgi?id=49856">49856</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>SCEV: Assertion `L && L->getHeader() == P->getParent()' failed in getRangeForUnknownRecurrence
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

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

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>new bugs
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>max.kazantsev@azul.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>The following test fails with opt -analyze -scalar-evolution:

target datalayout =
"e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128-ni:1-p2:32:8:8:32-ni:2"
target triple = "x86_64-unknown-linux-gnu"

define void @test() {
bb:
  br label %bb1

bb1:                                              ; preds = %bb
  br label %bb5

bb2:                                              ; preds = %bb2
  br label %bb2

bb3:                                              ; preds = %bb3
  br label %bb3

bb4:                                              ; preds = %bb4
  br label %bb4

bb5:                                              ; preds = %bb9, %bb1
  %tmp = phi i32 [ 2, %bb1 ], [ %tmp6, %bb9 ]
  %tmp6 = add nuw nsw i32 %tmp, 1
  %tmp7 = icmp ult i32 %tmp6, undef
  br i1 %tmp7, label %bb13, label %bb18

bb8:                                              ; preds = %bb8
  br label %bb8

bb9:                                              ; No predecessors!
  br label %bb5

bb10:                                             ; preds = %bb10
  br label %bb10

bb11:                                             ; preds = %bb11
  br label %bb11

bb12:                                             ; preds = %bb12
  br label %bb12

bb13:                                             ; preds = %bb5
  br label %bb14

bb14:                                             ; preds = %bb14, %bb13
  %tmp15 = phi i32 [ %tmp16, %bb14 ], [ undef, %bb13 ]
  %tmp16 = add nsw i32 %tmp15, 1
  %tmp17 = icmp sgt i32 %tmp16, 25
  br i1 %tmp17, label %bb19, label %bb14

bb18:                                             ; preds = %bb5
  unreachable

bb19:                                             ; preds = %bb14
  ret void
}

Offending patch:

commit ae7b1e8823a51068cfa64875fc5222e5b1d16760
Author: Philip Reames <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>>
Date:   Wed Mar 31 10:29:21 2021 -0700

    [SCEV] Handle unreachable binop when matching shift recurrence

    This fixes an issue introduced with my change d4648e, and reported in
pr49768.

    The root problem is that dominance collapses in unreachable code, and that
LoopInfo explicitly only models reachable code.  Since the recurrence matcher
doesn't filter by reachability (and can't easily because not all consumers have
domtree), we need to bailout before assuming that finding a recurrence implies
we found a 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>