[Mlir-commits] [mlir] [mlir][LLVM] Add !invariant.load metadata support to llvm.load (PR #76754)

Christian Ulmann llvmlistbot at llvm.org
Tue Jan 2 23:22:17 PST 2024


================
@@ -370,6 +370,19 @@ define void @load_store(ptr %ptr) {
 
 ; // -----
 
+; CHECK-LABEL: @invariant_load
+; CHECK-SAME:  %[[PTR:[a-zA-Z0-9]+]]
+define float @invariant_load(ptr %ptr) {
+  ; CHECK:  %[[V:[0-9]+]] = llvm.load %[[PTR]] {alignment = 4 : i64, invariantLoad} : !llvm.ptr -> f32
+  %1 = load float, ptr %ptr, align 4, !invariant.load !0
+  ; CHECK:  llvm.return %[[V]]
+  ret float %1
+}
+
+!0 = !{i32 1}
----------------
Dinistro wrote:

This seems to be incorrect, at least according to the LLVM IR lang ref:

> The optional !invariant.load metadata must reference a single metadata name <empty_node> corresponding to a metadata node with no entries.

Thus, it should just be the empty node `!0 = !{}`

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


More information about the Mlir-commits mailing list