Issue 91292
Summary Can `prefetchw`+`mov` to that location be folded to a `movnti`?
Labels new issue
Assignees
Reporter Validark
    See title. Please pardon my ignorance on this topic but I am not really sure how to look up the answer to this kind of question. 

I have this Zig code:

```zig
export fn movnti(dest: *u32, src: u32) void {
    @prefetch(dest, .{ .rw = .write, .locality = 0 });
    dest.* = src;
}
```

Here is the LLVM IR:

```llvm
define dso_local void @movnti(ptr nocapture nonnull align 4 %0, i32 %1) local_unnamed_addr {
Entry:
  tail call void @llvm.prefetch.p0(ptr nonnull %0, i32 1, i32 0, i32 1)
  store i32 %1, ptr %0, align 4
  ret void
}

declare void @llvm.dbg.value(metadata, metadata, metadata) #1

declare void @llvm.prefetch.p0(ptr nocapture readonly, i32 immarg, i32 immarg, i32 immarg) #2
```

Currently turns into this on x86 Zen 3:

```asm
movnti:
        prefetchw byte ptr [rdi]
        mov     dword ptr [rdi], esi
 ret
```

My question is, could this be turned into a `movnti` instruction?

Thank you.

https://zig.godbolt.org/z/hffbv46vs
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to