Break circular dependency between FIR dialect and utilities
[llvm-project.git] / flang / test / Lower / Intrinsics / len_trim.f90
blob8777e5857609f2806b9a1e5adf6fddc1a38841b0
1 ! RUN: bbc -emit-fir %s -o - | FileCheck %s
3 ! CHECK-LABEL: len_trim_test
4 integer function len_trim_test(c)
5 character(*) :: c
6 ltrim = len_trim(c)
7 ! CHECK-DAG: %[[c0:.*]] = arith.constant 0 : index
8 ! CHECK-DAG: %[[c1:.*]] = arith.constant 1 : index
9 ! CHECK-DAG: %[[cm1:.*]] = arith.constant -1 : index
10 ! CHECK-DAG: %[[lastChar:.*]] = arith.subi {{.*}}, %[[c1]]
11 ! CHECK: %[[iterateResult:.*]]:2 = fir.iterate_while (%[[index:.*]] = %[[lastChar]] to %[[c0]] step %[[cm1]]) and ({{.*}}) iter_args({{.*}}) {
12 ! CHECK: %[[addr:.*]] = fir.coordinate_of {{.*}}, %[[index]]
13 ! CHECK: %[[codeAddr:.*]] = fir.convert %[[addr]]
14 ! CHECK: %[[code:.*]] = fir.load %[[codeAddr]]
15 ! CHECK: %[[bool:.*]] = arith.cmpi eq
16 ! CHECK: fir.result %[[bool]], %[[index]]
17 ! CHECK: }
18 ! CHECK: %[[len:.*]] = arith.addi %[[iterateResult]]#1, %[[c1]]
19 ! CHECK: select %[[iterateResult]]#0, %[[c0]], %[[len]]
20 end function