47 lines · plain
1// RUN: fir-opt --canonicalize %s | FileCheck %s2 3// CHECK-LABEL: @ftest4func.func @ftest(%x : i1) -> i1 {5 // this pair of converts should be folded and DCEd6 %1 = fir.convert %x : (i1) -> !fir.logical<1>7 %2 = fir.convert %1 : (!fir.logical<1>) -> i18 // CHECK-NEXT: return %{{.*}} : i19 return %2 : i110}11 12// CHECK-LABEL: @gtest13func.func @gtest(%x : !fir.logical<2>) -> !fir.logical<2> {14 // this pair of converts should be folded and DCEd15 %1 = fir.convert %x : (!fir.logical<2>) -> i116 %2 = fir.convert %1 : (i1) -> !fir.logical<2>17 // CHECK-NEXT: return %{{.*}} : !fir.logical<2>18 return %2 : !fir.logical<2>19}20 21// CHECK-LABEL: @htest22func.func @htest(%x : !fir.int<4>) -> !fir.int<4> {23 // these converts are NOPs and should be folded away24 %1 = fir.convert %x : (!fir.int<4>) -> !fir.int<4>25 %2 = fir.convert %1 : (!fir.int<4>) -> !fir.int<4>26 // CHECK-NEXT: return %{{.*}} : !fir.int<4>27 return %2 : !fir.int<4>28}29 30// CHECK-LABEL: @ctest31func.func @ctest() -> index {32 %1 = arith.constant 10 : i3233 %2 = fir.convert %1 : (i32) -> index34 // CHECK-NEXT: %{{.*}} = arith.constant 10 : index35 // CHECK-NEXT: return %{{.*}} : index36 return %2 : index37}38 39// CHECK-LABEL: func.func @ptrtest(40// CHECK-SAME: %[[VAL_0:.*]]: !fir.heap<!fir.array<2xf32>>) -> !fir.heap<!fir.array<2xf32>> {41func.func @ptrtest(%0 : !fir.heap<!fir.array<2xf32>>) -> !fir.heap<!fir.array<2xf32>> {42 %1 = fir.convert %0 : (!fir.heap<!fir.array<2xf32>>) -> !fir.ref<!fir.array<2xf32>>43 %2 = fir.convert %1 : (!fir.ref<!fir.array<2xf32>>) -> !fir.heap<!fir.array<2xf32>>44// CHECK: return %[[VAL_0]] : !fir.heap<!fir.array<2xf32>>45 return %2 : !fir.heap<!fir.array<2xf32>>46}47