[libcxx-commits] [lldb] [lld] [llvm] [libc] [libcxx] [flang] [compiler-rt] [clang-tools-extra] [clang] [GlobalISel] Add G_PREFETCH (PR #74863)

Stanislav Mekhanoshin via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 11 11:01:20 PST 2023


================
@@ -1209,6 +1209,15 @@ def G_FENCE : GenericInstruction {
   let hasSideEffects = true;
 }
 
+// Generic opcode equivalent to the llvm.prefetch intrinsic.
+def G_PREFETCH : GenericInstruction {
+  let OutOperandList = (outs);
+  let InOperandList = (ins ptype0:$address, i32imm:$rw, i32imm:$locality, i32imm:$cachetype);
+  let hasSideEffects = true;
+  let mayLoad = true;
+  let mayStore = true;
----------------
rampitec wrote:

> should probably just be hasSideEffects. mayLoad/mayStore imply it needs a memory operand and is an ordered memory reference when it doesn't have one

I could argue this is not a memory operation at all as it shall have no visible effects other than access speed, although practically it has ordering. You certainly do not want a prefetch to be moved past the loads which it was supposed to prefetch. I.e. in my view use of both mayLoad and mayStore is justified. Although we need to make sure it is not considered an aliased store or load from the AA point of view.

https://github.com/llvm/llvm-project/pull/74863


More information about the libcxx-commits mailing list