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

    <tr>
        <th>Summary</th>
        <td>
            [ScopedNoAliasAA] Should ScopedNoAliasAA be more conservative in getting ModRef?
        </td>
    </tr>

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

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

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

<pre>
    This IR is reduced from https://github.com/rust-lang/rust/issues/116976.

```llvm
declare void @use(i64)

define i64 @foo(ptr noalias nocapture noundef align 8 dereferenceable(24) %p) {
  %p1 = getelementptr inbounds i8, ptr %p, i64 16
  %v1 = load i64, ptr %p1, align 8
  call void @use(i64 %v1)
 %p2 = getelementptr inbounds i8, ptr %p, i64 8
  call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %p2, i8 0, i64 16, i1 false), !alias.scope !0
  %v2 = load i64, ptr %p1, align 8, !noalias !0
  ret i64 %v2
}

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #0

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: write) }

!0 = !{!1}
!1 = distinct !{!1, !2}
!2 = distinct !{!2}
```

godbolt: https://llvm.godbolt.org/z/7sTrhYdMo

Currently, GVN replaces `%v2` with `%v1`.
Maybe I'm missing something here. Other passes may have provided incorrect alias information.

>From the [LLVM Alias Analysis Infrastructure](https://www.llvm.org/docs/AliasAnalysis.html), my understanding is that the `alias` method returns alias when two memory objects alias **each other**. And the `getModRefInfo` returns `ModRef` when **an/any alias exists**.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykVVGP4yYQ_jXkZXQWJrHjPOQhe1GqVW-v6t3ppD5iGMe0GCLASdNfXwH2rnfbrlpVimIDwzcz33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