|
87 | 87 | fir.array_merge_store %3, %4 to %arg1 : !fir.array<100xf32>, !fir.array<100xf32>, !fir.ptr<!fir.array<100xf32>>
|
88 | 88 | return
|
89 | 89 | }
|
| 90 | + |
| 91 | +// Test derived_target(:)%i = integer_pointer(:) |
| 92 | +// The integer pointer may be aliasing the derived target component. |
| 93 | +// CHECK-LABEL: func @derived_whose_component_may_be_aliased |
| 94 | +// CHECK: fir.allocmem !fir.array<4x!fir.type<some_type{i:i32}>> |
| 95 | +func @derived_whose_component_may_be_aliased(%arg0: !fir.box<!fir.array<4x!fir.type<some_type{i:i32}>>> {fir.target}, %arg1: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>) { |
| 96 | + %c4 = arith.constant 4 : index |
| 97 | + %0 = fir.field_index i, !fir.type<some_type{i:i32}> |
| 98 | + %c1 = arith.constant 1 : index |
| 99 | + %1 = fir.slice %c1, %c4, %c1 path %0 : (index, index, index, !fir.field) -> !fir.slice<1> |
| 100 | + %2 = fir.array_load %arg0 [%1] : (!fir.box<!fir.array<4x!fir.type<some_type{i:i32}>>>, !fir.slice<1>) -> !fir.array<4xi32> |
| 101 | + %3 = fir.load %arg1 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> |
| 102 | + %c0 = arith.constant 0 : index |
| 103 | + %4:3 = fir.box_dims %3, %c0 : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, index) -> (index, index, index) |
| 104 | + %5 = fir.shift %4#0 : (index) -> !fir.shift<1> |
| 105 | + %6 = fir.array_load %3(%5) : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, !fir.shift<1>) -> !fir.array<?xi32> |
| 106 | + %7 = arith.subi %c4, %c1 : index |
| 107 | + %8 = fir.do_loop %arg2 = %c0 to %7 step %c1 unordered iter_args(%arg3 = %2) -> (!fir.array<4xi32>) { |
| 108 | + %9 = fir.array_fetch %6, %arg2 : (!fir.array<?xi32>, index) -> i32 |
| 109 | + %10 = fir.array_update %arg3, %9, %arg2 : (!fir.array<4xi32>, i32, index) -> !fir.array<4xi32> |
| 110 | + fir.result %10 : !fir.array<4xi32> |
| 111 | + } |
| 112 | + fir.array_merge_store %2, %8 to %arg0[%1] : !fir.array<4xi32>, !fir.array<4xi32>, !fir.box<!fir.array<4x!fir.type<some_type{i:i32}>>>, !fir.slice<1> |
| 113 | + return |
| 114 | +} |
| 115 | + |
| 116 | +// Test real_target = complex_target(:)%re |
| 117 | +// The real pointer may be aliasing the complex real part. |
| 118 | +// CHECK-LABEL: func @complex_real_aliasing |
| 119 | +// CHECK: fir.allocmem !fir.array<?xf32> |
| 120 | +func @complex_real_aliasing(%arg0: !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>>, %arg1: !fir.ref<!fir.array<4x!fir.complex<4>>> {fir.target}) { |
| 121 | + %c4 = arith.constant 4 : index |
| 122 | + %0 = fir.load %arg0 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xf32>>>> |
| 123 | + %c0 = arith.constant 0 : index |
| 124 | + %1:3 = fir.box_dims %0, %c0 : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, index) -> (index, index, index) |
| 125 | + %2 = fir.shift %1#0 : (index) -> !fir.shift<1> |
| 126 | + %3 = fir.array_load %0(%2) : (!fir.box<!fir.ptr<!fir.array<?xf32>>>, !fir.shift<1>) -> !fir.array<?xf32> |
| 127 | + %c0_i32 = arith.constant 0 : i32 |
| 128 | + %4 = fir.shape %c4 : (index) -> !fir.shape<1> |
| 129 | + %c1 = arith.constant 1 : index |
| 130 | + %5 = fir.slice %c1, %c4, %c1 path %c0_i32 : (index, index, index, i32) -> !fir.slice<1> |
| 131 | + %6 = fir.array_load %arg1(%4) [%5] : (!fir.ref<!fir.array<4x!fir.complex<4>>>, !fir.shape<1>, !fir.slice<1>) -> !fir.array<4xf32> |
| 132 | + %7 = arith.subi %c4, %c1 : index |
| 133 | + %8 = fir.do_loop %arg2 = %c0 to %7 step %c1 unordered iter_args(%arg3 = %3) -> (!fir.array<?xf32>) { |
| 134 | + %9 = fir.array_fetch %6, %arg2 : (!fir.array<4xf32>, index) -> f32 |
| 135 | + %10 = fir.array_update %arg3, %9, %arg2 : (!fir.array<?xf32>, f32, index) -> !fir.array<?xf32> |
| 136 | + fir.result %10 : !fir.array<?xf32> |
| 137 | + } |
| 138 | + fir.array_merge_store %3, %8 to %0 : !fir.array<?xf32>, !fir.array<?xf32>, !fir.box<!fir.ptr<!fir.array<?xf32>>> |
| 139 | + return |
| 140 | +} |
| 141 | + |
0 commit comments