1 // RUN: fir-opt --canonicalize %s | FileCheck %s
4 func.func @ftest(%x : i1) -> i1 {
5 // this pair of converts should be folded and DCEd
6 %1 = fir.convert %x : (i1) -> !fir.logical<1>
7 %2 = fir.convert %1 : (!fir.logical<1>) -> i1
8 // CHECK-NEXT: return %{{.*}} : i1
12 // CHECK-LABEL: @gtest
13 func.func @gtest(%x : !fir.logical<2>) -> !fir.logical<2> {
14 // this pair of converts should be folded and DCEd
15 %1 = fir.convert %x : (!fir.logical<2>) -> i1
16 %2 = fir.convert %1 : (i1) -> !fir.logical<2>
17 // CHECK-NEXT: return %{{.*}} : !fir.logical<2>
18 return %2 : !fir.logical<2>
21 // CHECK-LABEL: @htest
22 func.func @htest(%x : !fir.int<4>) -> !fir.int<4> {
23 // these converts are NOPs and should be folded away
24 %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>
30 // CHECK-LABEL: @ctest
31 func.func @ctest() -> index {
32 %1 = arith.constant 10 : i32
33 %2 = fir.convert %1 : (i32) -> index
34 // CHECK-NEXT: %{{.*}} = arith.constant 10 : index
35 // CHECK-NEXT: return %{{.*}} : index