brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 75803bf Raw
34 lines · plain
1// Test that the HLFIR pipeline does not call MLIR canonicalizer with block2// merging enabled (moving fir.shape to block argument would cause failures3// when translating the FIR to LLVM).4// RUN: %flang_fc1 %s -flang-experimental-hlfir -emit-llvm -O2 -o - | FileCheck %s5 6func.func @no_shape_merge(%cdt: i1, %from: !fir.ref<!fir.array<?xf64>>, %to : !fir.ref<f64>) {7  %c10 = arith.constant 10 : index8  %c20 = arith.constant 20 : index9  %c5 = arith.constant 5 : index10  %shape1 = fir.shape %c10 : (index) -> !fir.shape<1>11  %shape2 = fir.shape %c20 : (index) -> !fir.shape<1>12  cf.cond_br %cdt, ^bb1, ^bb213^bb1:  // pred: ^bb014  %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 ^bb318^bb2:  // pred: ^bb019  %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 ^bb323^bb3:  // pred: ^bb1, ^bb224  return25}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 void34