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

    <tr>
        <th>Summary</th>
        <td>
            [AMDGPU] "Not a virtual register" assertion in libc math tests
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            libc
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          jhuber6
      </td>
    </tr>
</table>

<pre>
    The following IR has begun to hit this assertion at `-O2`. I reduced the test case to the following code .https://godbolt.org/z/TYsf3j1dv.

```llvm
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
target triple = "amdgcn-amd-amdhsa"

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p5(i64 immarg, ptr addrspace(5) captures(none)) #0

define double @_ZN22__llvm_libc_21_0_0_git6fputil4sqrtIddEENS_3cpp9enable_ifIXaaaasr3cppE19is_floating_point_vIT_Esr3cppE19is_floating_point_vIT0_ElestS4_stS5_ES4_E4typeES5_(i64 %0) {
entry:
  br label %for.body

for.cond.cleanup: ; preds = %for.body
  %cmp3.not.i.i.i = icmp eq i64 %r.0108, 0
 br i1 %cmp3.not.i.i.i, label %cleanup, label %if.end26.i.i

if.end26.i.i: ; preds = %for.cond.cleanup
  call void @llvm.lifetime.end.p5(i64 0, ptr addrspace(5) null)
  br label %cleanup

for.body:                                         ; preds = %for.body, %entry
  %current_bit.01093 = phi i64 [ 2251799813685248, %entry ], [ %shr.3, %for.body ]
  %r.0108 = phi i64 [ 0, %entry ], [ %shl28.3, %for.body ]
  %1 = or i64 %current_bit.01093, %0
  %shl28.3 = or i64 %1, %r.0108
  %shr.3 = lshr i64 %current_bit.01093, 1
  %tobool27.not.3 = icmp eq i64 %current_bit.01093, 0
  br i1 %tobool27.not.3, label %for.cond.cleanup, label %for.body

cleanup: ; preds = %if.end26.i.i, %for.cond.cleanup
  ret double 0.000000e+00
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVs1ypDYQfhrNRQWlH2DgMAe8ntnyIZtUvKlKcqEE0oA2QmIlgct5-pQEY8-sd117CMZipO7-Wt396Yc5J3stxAHkdyC_37HZD8YevgxzK2yxaw1_PnweBDwbpcyT1D18-B0OzMFW9LOG3sBBeugH6SBzTlgvjYbMQ1Cg5FcCCpTCB2gFnzvBoR8E9MJ52DEngq2_Qe4MFzAdvJ8coDUgJ0BOveGtUT41tgfk9C8gp89_uTP9gvmSAlSHt0Drq9QyAlR7ZnvhIWeeKfZsZg8BvYeAEJFMgNZFFptkwtcdAmhN1yaZ6HUnu1bLryXFdWcPaI0LBGhN8uKlDZIySMjWJlMVflTkraK8eFlwEcGShWSraLm4WbJy06mKDXB5AUuWF8RkyXEYzTFJFowiTvgkC0ERInwSHWGLLHmkJKnz5CNOtAS0DrEEpQoQ8ppQb-WkxCWZbOR9pxM28vA_OLbqhpfewdOsu8iE2nsbigm16ZhSLev-gdqcrRBQG_esO6jNrJ-k5vBJKmWFn62GoxiNfQakZLYfxRjsrWD8yUovAKkAqrnoFLMCLkZyCLJY-1TJs_ByFKnQPJ1yQEpZZFCOIwvk-QAnbyHj3LqJdQKQMgekgh2b_GyFA6TURkd4UkFAKFrD4eIstYDczG2IPkPN358IaZrgsVGy7RqCG9Sgppe-OE-zlypzX61_4Px4_PTY0G6aKqFZq0Qjzw9_MsaYs2H0iCvpmrMyzEvdN5OR2jfLw-fm-L4cNUclnH_MGucf8-b4mDXHzD9P4viYN1vQgOQoxrG_A6gW2tvnsKRQDWFroWKtUEH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