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

    <tr>
        <th>Summary</th>
        <td>
            memcpyopt fails with Assertion `Parent == Other->Parent && "cross-BB instruction order comparison"' failed.
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          serge-sans-paille
      </td>
    </tr>
</table>

<pre>
    While compiling firefox with clang from 253a52988fe37887ba1f7741271d602083fe7dd7 , I hit an assert.

The following (reduced) test case fails on `opt '-passes=early-cse,memcpyopt' -S cross-block.ll`  where `cross-block.ll` contains

```llvm
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"

define void @test_case(ptr %this, ptr %aFrame, i1 %call14) unnamed_addr {
entry:
  %r = alloca %struct.nsRect
  %ref.tmp18 = alloca %struct.nsRect
  %x = getelementptr inbounds %struct.nsRect, ptr %r, i32 0, i32 0
  store i32 0, ptr %x
  br i1 %call14, label %if.then17, label %if.end21

if.then17:
  call void @fwd_decl(ptr %ref.tmp18, ptr %r)
  call void @llvm.memcpy.p0.p0.i64(ptr %r, ptr %ref.tmp18, i64 16, i1 false)
  br label %if.end21

if.end21:
  ret void
}

declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg)

declare hidden void @fwd_decl(ptr, ptr )
```

I couldn't remove the `ealy-cse` pass :-/
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyMVUGPqzYQ_jXOZQSCMQFy4LD70kjv1KqvUo8rg4fg1tjINpvNv6_sJJvsbqs-CRF7PDOe75vhi_BeHQ1Rx7bPbLvfiDVM1nWe3JEyL4zPFqG0pk1v5bn7c1KaYLDzorQyRxiVo9G-wUmFCQYtosnZGXDLxRZ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