Files
TheRock/compiler/amd-llvm/flang/test/Transforms/FIRToMemRef/array-coor-block-arg.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

68 lines
3.3 KiB
MLIR

// Verify fir.array_coor lowering when the base is a block argument.
// This used to take a shortcut (convert the element ref result) which kept the
// fir.array_coor alive. We prefer converting the base to a memref and
// computing indices so that fir.array_coor can be erased when only used by
// load/store.
//
// RUN: fir-opt %s --fir-to-memref --allow-unregistered-dialect | FileCheck %s
func.func @block_arg_memref(%arg0: !fir.ref<!fir.array<32xi32>>) {
%c32 = arith.constant 32 : index
%c1 = arith.constant 1 : index
%c1_i32 = arith.constant 1 : i32
%shape = fir.shape %c32 : (index) -> !fir.shape<1>
%elt = fir.array_coor %arg0(%shape) %c1 : (!fir.ref<!fir.array<32xi32>>, !fir.shape<1>, index) -> !fir.ref<i32>
fir.store %c1_i32 to %elt : !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @block_arg_memref
// CHECK: [[BASE:%.+]] = fir.convert %arg0 : (!fir.ref<!fir.array<32xi32>>) -> memref<32xi32>
// CHECK: [[ONE:%.+]] = arith.constant 1 : index
// CHECK: [[SUB:%.+]] = arith.subi %c1, [[ONE]] : index
// CHECK: [[MUL:%.+]] = arith.muli [[SUB]], [[ONE]] : index
// CHECK: [[SUB2:%.+]] = arith.subi [[ONE]], [[ONE]] : index
// CHECK: [[IDX:%.+]] = arith.addi [[MUL]], [[SUB2]] : index
// CHECK: memref.store {{%.+}}, [[BASE]][[[IDX]]] : memref<32xi32>
// CHECK-NOT: fir.array_coor
// Verify fir.array_coor lowering when the base is a boxed function argument.
// The pass must materialize fir.box_addr
// first and must not emit an illegal direct box->memref fir.convert.
func.func @block_arg_boxed_array(%arg0: !fir.box<!fir.array<?xi32>>) {
%c1_i32 = arith.constant 1 : i32
%c1_i64 = arith.constant 1 : i64
%elt = fir.array_coor %arg0 %c1_i64 : (!fir.box<!fir.array<?xi32>>, i64) -> !fir.ref<i32>
fir.store %c1_i32 to %elt : !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @block_arg_boxed_array
// CHECK: [[BOXADDR:%.+]] = fir.box_addr %arg0
// CHECK: [[BASE:%.+]] = fir.convert [[BOXADDR]] : (!fir.ref<!fir.array<?xi32>>) -> memref<?xi32{{.*}}>
// CHECK-NOT: fir.convert %arg0 : (!fir.box<!fir.array<?xi32>>) -> memref
// CHECK: memref.store {{%.+}}, {{%.+}}[{{%.+}}] : memref<?xi32, strided<[?], offset: ?>>
// CHECK-NOT: fir.array_coor
// Verify fir.array_coor lowering keeps descriptor stride semantics when the
// box element type has static extent. A boxed section may still be strided.
func.func @block_arg_boxed_static_array(%arg0: !fir.box<!fir.array<5xi32>>) {
%c1_i32 = arith.constant 1 : i32
%c2_i64 = arith.constant 2 : i64
%elt = fir.array_coor %arg0 %c2_i64 : (!fir.box<!fir.array<5xi32>>, i64) -> !fir.ref<i32>
fir.store %c1_i32 to %elt : !fir.ref<i32>
return
}
// CHECK-LABEL: func.func @block_arg_boxed_static_array
// CHECK: [[BOXADDR:%.+]] = fir.box_addr %arg0
// CHECK: [[BASE:%.+]] = fir.convert [[BOXADDR]] : (!fir.ref<!fir.array<5xi32>>) -> memref<5xi32>
// CHECK: [[ELE:%.+]] = fir.box_elesize
// CHECK: [[DIMS:%.+]]:3 = fir.box_dims
// CHECK: [[DIV:%.+]] = arith.divsi {{%.+}}, [[ELE]] : index
// CHECK: [[REINT:%.+]] = memref.reinterpret_cast [[BASE]]
// CHECK-SAME: : memref<5xi32> to memref<?xi32, strided<[?], offset: ?>>
// CHECK: memref.store {{%.+}}, [[REINT]][{{%.+}}] : memref<?xi32, strided<[?], offset: ?>>
// CHECK-NOT: fir.array_coor