<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/129554>129554</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Clarification: EPResumeVal && "must have a resume value for the canonical IV" assert vs downstream changes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          t-larina
      </td>
    </tr>
</table>

<pre>
    I work at Qualcomm, and I am finding this [patch](https://github.com/llvm/llvm-project/commit/0e70289f373d40f3f8a4cc5c35dd02bfe909ca83) conflicts with some of our downstream changes. We're generating an IR with two PHIs in a basic block when optimizing this simple source [loop_i.txt](https://github.com/user-attachments/files/18855201/loop_i.txt), relevant IR snippet (full IR [loop_ll.txt](https://github.com/user-attachments/files/18855202/loop_ll.txt) ):

define dso_local noundef i32 @​main() local_unnamed_addr #0 {
entry:
br label %for.body

for.body: ; preds = %entry, %for.body
%arrayidx.phi = phi ptr [ @​buffer1, %entry ], [ %arrayidx.inc, %for.body ]
%i.017 = phi i32 [ 0, %entry ], [ %inc, %for.body ]
%i.118 = phi i32 [ 0, %entry ], [ %inc8, %for.body ]
%conv = trunc nuw i32 %i.017 to i8
store i8 %conv, ptr %arrayidx.phi, align 1, !tbaa !3
.......

Is having two PHIs valid IR code in the patch context? If so, the assertion EPResumeVal && "must have a resume value for the canonical IV" fails because find_singleton finds two PHIs instead of one and returns null as a consequence. A conservative fix would be to continue without processing EPResumeVal when more than one phi exists, in a manner similar to the functionality this patch replaced. If two PHIs are not valid, well, there's my problem.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVcGO2zYQ_Rr6MoggUZYtHXzwbmLUtzSH9LgYkSOLDUWqJGXv9uuLoXY32aBNESCGAVoW-ebN48wbjNFcHNFBNHeieb_BJY0-HNI7i8E43PRePx3OcPPhC2CC3xe0yk-TkPeAT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