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

Tobias Gysi llvmlistbot at llvm.org
Tue Jan 2 23:48:27 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
----------------
gysit wrote:

Can you add the invariant flag to the assembly format since it is an inherent attribute. I know we don't do this consistently but at least for new flags it would be nice to not print them in the attribute dictionary.

I would probably add it between atomic ordering and attr-dict:
```
    (`volatile` $volatile_^)? $addr
    (`atomic` (`syncscope` `(` $syncscope^ `)`)? $ordering^)?
    (`invariant` $isInvariant^)? 
    attr-dict `:` qualified(type($addr)) `->` type($res)
```
After that a small roundtrip test may make sense as well.

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


More information about the Mlir-commits mailing list