| 1 |
// Test that the HLFIR pipeline does not call MLIR canonicalizer with block |
| 2 |
// merging enabled (moving fir.shape to block argument would cause failures |
| 3 |
// when translating the FIR to LLVM). |
| 4 |
// RUN: %flang_fc1 %s -flang-experimental-hlfir -emit-llvm -O2 -o - | FileCheck %s |
| 5 |
|
| 6 |
func.func @no_shape_merge(%cdt: i1, %from: !fir.ref<!fir.array<?xf64>>, %to : !fir.ref<f64>) { |
| 7 |
%c10 = arith.constant 10 : index |
| 8 |
%c20 = arith.constant 20 : index |
| 9 |
%c5 = arith.constant 5 : index |
| 10 |
%shape1 = fir.shape %c10 : (index) -> !fir.shape<1> |
| 11 |
%shape2 = fir.shape %c20 : (index) -> !fir.shape<1> |
| 12 |
cf.cond_br %cdt, ^bb1, ^bb2 |
| 13 |
^bb1: // pred: ^bb0 |
| 14 |
%coor1 = fir.array_coor %from(%shape1) %c5 : (!fir.ref<!fir.array<?xf64>>, !fir.shape<1>, index) -> !fir.ref<f64> |
| 15 |
%load1 = fir.load %coor1 : !fir.ref<f64> |
| 16 |
fir.store %load1 to %to : !fir.ref<f64> |
| 17 |
cf.br ^bb3 |
| 18 |
^bb2: // pred: ^bb0 |
| 19 |
%coor2 = fir.array_coor %from(%shape2) %c5 : (!fir.ref<!fir.array<?xf64>>, !fir.shape<1>, index) -> !fir.ref<f64> |
| 20 |
%load2 = fir.load %coor2 : !fir.ref<f64> |
| 21 |
fir.store %load2 to %to : !fir.ref<f64> |
| 22 |
cf.br ^bb3 |
| 23 |
^bb3: // pred: ^bb1, ^bb2 |
| 24 |
return |
| 25 |
} |
| 26 |
|
| 27 |
// Note: block merging happens in the output below, but after FIR codegen. |
| 28 |
|
| 29 |
// CHECK-LABEL: define void @no_shape_merge( |
| 30 |
// CHECK: %[[GEP:.*]] = getelementptr i8, ptr %{{.*}} |
| 31 |
// CHECK: %[[LOAD:.*]] = load double, ptr %[[GEP]] |
| 32 |
// CHECK: store double %[[LOAD]], ptr %{{.*}} |
| 33 |
// CHECK: ret void |