[flang-commits] [flang] [mlir] [mlir] Align num elements type to LLVM ArrayType (PR #93230)
Tobias Gysi via flang-commits
flang-commits at lists.llvm.org
Thu May 23 23:13:57 PDT 2024
================
@@ -2698,3 +2698,9 @@ func.func @coordinate_array_unknown_size_1d(%arg0: !fir.ptr<!fir.array<? x i32>>
// CHECK: %[[VAL_2:.*]] = llvm.getelementptr %[[VAL_0]]{{\[}}%[[VAL_1]]] : (!llvm.ptr, i64) -> !llvm.ptr, i32
// CHECK: llvm.return
// CHECK: }
+
+// -----
+
+fir.global common @c_(dense<0> : vector<4294967296xi8>) : !fir.array<4294967296xi8>
+
+// CHECK: llvm.mlir.global common @c_(dense<0> : vector<4294967296xi8>) {addr_space = 0 : i32} : !llvm.array<4294967296 x i8>
----------------
gysit wrote:
We also have a zero operation for zero initialized types that uses `llvm::Constant::getNullValue` during the lowering to LLVM. This should be efficient for any kind of zero initialized values:
```
llvm.mlir.global common @c)() {addr_space = 0 : i32} : !llvm.array<4294967296 x i8> {
%0 = llvm.mlir.zero : !llvm.array<4294967296 x i8>
llvm.return %0 : !llvm.array<4294967296 x i8>
}
```
Note: that your change to the constant lowering still makes sense since there are multiple ways of expressing a zero constant and ideally all of them are efficient in the lowering.
https://github.com/llvm/llvm-project/pull/93230
More information about the flang-commits
mailing list