1 // Test hlfir.concat operation lowering to operations operating on memory.
3 // RUN: fir-opt %s -bufferize-hlfir | FileCheck %s
5 func.func @_QPmax1(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
6 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
7 %1:2 = hlfir.declare %0#0 typeparams %0#1 {uniq_name = "_QFmax1Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
8 %2:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
9 %3:2 = hlfir.declare %2#0 typeparams %2#1 {uniq_name = "_QFmax1Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
10 %4:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
11 %5:2 = hlfir.declare %4#0 typeparams %4#1 {uniq_name = "_QFmax1Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
12 %6 = hlfir.char_extremum max, %3#0, %5#0 : (!fir.boxchar<1>, !fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
13 hlfir.assign %6 to %1#0 : !hlfir.expr<!fir.char<1,?>>, !fir.boxchar<1>
14 hlfir.destroy %6 : !hlfir.expr<!fir.char<1,?>>
18 // CHECK: func.func @_QPmax1(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
19 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
20 // CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]]#0 typeparams %[[VAL_0]]#1 {uniq_name = "_QFmax1Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
21 // CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
22 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]#0 typeparams %[[VAL_2]]#1 {uniq_name = "_QFmax1Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
23 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
24 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFmax1Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
25 // CHECK: %[[VAL_6:.*]] = arith.cmpi uge, %[[VAL_2]]#1, %[[VAL_4]]#1 : index
26 // CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_2]]#1, %[[VAL_4]]#1 : index
27 // CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_5]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
28 // CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
29 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
30 // CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
31 // CHECK: %[[VAL_12:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_8]], %[[VAL_9]], %[[VAL_10]], %[[VAL_11]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
32 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
33 // CHECK: %[[VAL_13:.*]] = arith.cmpi sgt, %[[VAL_12]], %[[C0_I32]] : i32
34 // CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_5]]#1, %[[VAL_3]]#1 : !fir.ref<!fir.char<1,?>>
35 // CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_13]], %[[VAL_4]]#1, %[[VAL_2]]#1 : index
36 // CHECK: %[[VAL_16:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_7]] : index) {bindc_name = ".chrtmp"}
37 // CHECK: %[[VAL_17:.*]] = arith.cmpi slt, %[[VAL_7]], %[[VAL_15]] : index
38 // CHECK: %[[VAL_18:.*]] = arith.select %[[VAL_17]], %[[VAL_7]], %[[VAL_15]] : index
39 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
40 // CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (index) -> i64
41 // CHECK: %[[VAL_20:.*]] = arith.muli %[[C1_I64]], %[[VAL_19]] : i64
42 // CHECK: %[[FALSE:.*]] = arith.constant false
43 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
44 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
45 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_21]], %[[VAL_22]], %[[VAL_20]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
46 // CHECK: %[[C1:.*]] = arith.constant 1 : index
47 // CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_7]], %[[C1]] : index
48 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
49 // CHECK: %[[VAL_24:.*]] = fir.undefined !fir.char<1>
50 // CHECK: %[[VAL_25:.*]] = fir.insert_value %[[VAL_24]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
51 // CHECK: %[[C1_0:.*]] = arith.constant 1 : index
52 // CHECK: fir.do_loop %[[ARG3:.*]] = %[[VAL_18:.*]] to %[[VAL_23]] step %[[C1_0]] {
53 // CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
54 // CHECK: %[[VAL_31:.*]] = fir.coordinate_of %[[VAL_30]], %[[ARG3]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
55 // CHECK: fir.store %[[VAL_25:.*]] to %[[VAL_31]] : !fir.ref<!fir.char<1>>
57 // CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_16]] typeparams %[[VAL_7]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
58 // CHECK: %[[FALSE_1:.*]] = arith.constant false
59 // CHECK: %[[VAL_27:.*]] = fir.undefined tuple<!fir.boxchar<1>, i1>
60 // CHECK: %[[VAL_28:.*]] = fir.insert_value %[[VAL_27]], %[[FALSE_1]], [1 : index] : (tuple<!fir.boxchar<1>, i1>, i1) -> tuple<!fir.boxchar<1>, i1>
61 // CHECK: %[[VAL_29:.*]] = fir.insert_value %[[VAL_28]], %[[VAL_26]]#0, [0 : index] : (tuple<!fir.boxchar<1>, i1>, !fir.boxchar<1>) -> tuple<!fir.boxchar<1>, i1>
62 // CHECK: hlfir.assign %[[VAL_26]]#0 to %[[VAL_1]]#0 : !fir.boxchar<1>, !fir.boxchar<1>
66 func.func @_QPmin1(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
67 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
68 %1:2 = hlfir.declare %0#0 typeparams %0#1 {uniq_name = "_QFmin1Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
69 %2:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
70 %3:2 = hlfir.declare %2#0 typeparams %2#1 {uniq_name = "_QFmin1Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
71 %4:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
72 %5:2 = hlfir.declare %4#0 typeparams %4#1 {uniq_name = "_QFmin1Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
73 %6 = hlfir.char_extremum min, %3#0, %5#0 : (!fir.boxchar<1>, !fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
74 hlfir.assign %6 to %1#0 : !hlfir.expr<!fir.char<1,?>>, !fir.boxchar<1>
75 hlfir.destroy %6 : !hlfir.expr<!fir.char<1,?>>
79 // CHECK: func.func @_QPmin1(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
80 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
81 // CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]]#0 typeparams %[[VAL_0]]#1 {uniq_name = "_QFmin1Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
82 // CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
83 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]#0 typeparams %[[VAL_2]]#1 {uniq_name = "_QFmin1Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
84 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
85 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFmin1Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
86 // CHECK: %[[VAL_6:.*]] = arith.cmpi uge, %[[VAL_2]]#1, %[[VAL_4]]#1 : index
87 // CHECK: %[[VAL_7:.*]] = arith.select %[[VAL_6]], %[[VAL_2]]#1, %[[VAL_4]]#1 : index
88 // CHECK: %[[VAL_8:.*]] = fir.convert %[[VAL_5]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
89 // CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
90 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
91 // CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
92 // CHECK: %[[VAL_12:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_8]], %[[VAL_9]], %[[VAL_10]], %[[VAL_11]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
93 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
94 // CHECK: %[[VAL_13:.*]] = arith.cmpi slt, %[[VAL_12]], %[[C0_I32]] : i32
95 // CHECK: %[[VAL_14:.*]] = arith.select %[[VAL_13]], %[[VAL_5]]#1, %[[VAL_3]]#1 : !fir.ref<!fir.char<1,?>>
96 // CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_13]], %[[VAL_4]]#1, %[[VAL_2]]#1 : index
97 // CHECK: %[[VAL_16:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_7]] : index) {bindc_name = ".chrtmp"}
98 // CHECK: %[[VAL_17:.*]] = arith.cmpi slt, %[[VAL_7]], %[[VAL_15]] : index
99 // CHECK: %[[VAL_18:.*]] = arith.select %[[VAL_17]], %[[VAL_7]], %[[VAL_15]] : index
100 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
101 // CHECK: %[[VAL_19:.*]] = fir.convert %[[VAL_18]] : (index) -> i64
102 // CHECK: %[[VAL_20:.*]] = arith.muli %[[C1_I64]], %[[VAL_19]] : i64
103 // CHECK: %[[FALSE:.*]] = arith.constant false
104 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
105 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_14]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
106 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_21]], %[[VAL_22]], %[[VAL_20]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
107 // CHECK: %[[C1:.*]] = arith.constant 1 : index
108 // CHECK: %[[VAL_23:.*]] = arith.subi %[[VAL_7]], %[[C1]] : index
109 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
110 // CHECK: %[[VAL_24:.*]] = fir.undefined !fir.char<1>
111 // CHECK: %[[VAL_25:.*]] = fir.insert_value %[[VAL_24]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
112 // CHECK: %[[C1_0:.*]] = arith.constant 1 : index
113 // CHECK: fir.do_loop %[[ARG3:.*]] = %[[VAL_18:.*]] to %[[VAL_23]] step %[[C1_0]] {
114 // CHECK: %[[VAL_30:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
115 // CHECK: %[[VAL_31:.*]] = fir.coordinate_of %[[VAL_30]], %[[ARG3]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
116 // CHECK: fir.store %[[VAL_25:.*]] to %[[VAL_31]] : !fir.ref<!fir.char<1>>
118 // CHECK: %[[VAL_26:.*]]:2 = hlfir.declare %[[VAL_16]] typeparams %[[VAL_7]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
119 // CHECK: %[[FALSE_1:.*]] = arith.constant false
120 // CHECK: %[[VAL_27:.*]] = fir.undefined tuple<!fir.boxchar<1>, i1>
121 // CHECK: %[[VAL_28:.*]] = fir.insert_value %[[VAL_27]], %[[FALSE_1]], [1 : index] : (tuple<!fir.boxchar<1>, i1>, i1) -> tuple<!fir.boxchar<1>, i1>
122 // CHECK: %[[VAL_29:.*]] = fir.insert_value %[[VAL_28]], %[[VAL_26]]#0, [0 : index] : (tuple<!fir.boxchar<1>, i1>, !fir.boxchar<1>) -> tuple<!fir.boxchar<1>, i1>
123 // CHECK: hlfir.assign %[[VAL_26]]#0 to %[[VAL_1]]#0 : !fir.boxchar<1>, !fir.boxchar<1>
127 func.func @_QPmax2(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
128 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
129 %1 = fir.convert %0#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>>
130 %c100 = arith.constant 100 : index
131 %2 = fir.shape %c100 : (index) -> !fir.shape<1>
132 %3:2 = hlfir.declare %1(%2) typeparams %0#1 {uniq_name = "_QFmax2Ec1"} : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<100x!fir.char<1,?>>>, !fir.ref<!fir.array<100x!fir.char<1,?>>>)
133 %4:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
134 %c10 = arith.constant 10 : index
135 %5 = fir.convert %4#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,10>>>
136 %c100_0 = arith.constant 100 : index
137 %6 = fir.shape %c100_0 : (index) -> !fir.shape<1>
138 %7:2 = hlfir.declare %5(%6) typeparams %c10 {uniq_name = "_QFmax2Ec2"} : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,10>>>)
139 %8:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
140 %c20 = arith.constant 20 : index
141 %9 = fir.convert %8#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,20>>>
142 %c100_1 = arith.constant 100 : index
143 %10 = fir.shape %c100_1 : (index) -> !fir.shape<1>
144 %11:2 = hlfir.declare %9(%10) typeparams %c20 {uniq_name = "_QFmax2Ec3"} : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>)
145 %c1 = arith.constant 1 : index
146 %12 = hlfir.designate %7#0 (%c1) typeparams %c10 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
147 %c1_2 = arith.constant 1 : index
148 %13 = hlfir.designate %11#0 (%c1_2) typeparams %c20 : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, index, index) -> !fir.ref<!fir.char<1,20>>
149 %14 = hlfir.char_extremum max, %12, %13 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,20>>) -> !hlfir.expr<!fir.char<1,20>>
150 %c1_3 = arith.constant 1 : index
151 %15 = hlfir.designate %3#0 (%c1_3) typeparams %0#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
152 hlfir.assign %14 to %15 : !hlfir.expr<!fir.char<1,20>>, !fir.boxchar<1>
153 hlfir.destroy %14 : !hlfir.expr<!fir.char<1,20>>
157 // CHECK: func.func @_QPmax2(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
158 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
159 // CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>>
160 // CHECK: %[[C100:.*]] = arith.constant 100 : index
161 // CHECK: %[[VAL_2:.*]] = fir.shape %[[C100]] : (index) -> !fir.shape<1>
162 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) typeparams %[[VAL_0]]#1 {uniq_name = "_QFmax2Ec1"} : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<100x!fir.char<1,?>>>, !fir.ref<!fir.array<100x!fir.char<1,?>>>)
163 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
164 // CHECK: %[[C10:.*]] = arith.constant 10 : index
165 // CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,10>>>
166 // CHECK: %[[C100_0:.*]] = arith.constant 100 : index
167 // CHECK: %[[VAL_6:.*]] = fir.shape %[[C100_0]] : (index) -> !fir.shape<1>
168 // CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_6]]) typeparams %[[C10]] {uniq_name = "_QFmax2Ec2"} : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,10>>>)
169 // CHECK: %[[VAL_8:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
170 // CHECK: %[[C20:.*]] = arith.constant 20 : index
171 // CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,20>>>
172 // CHECK: %[[C100_1:.*]] = arith.constant 100 : index
173 // CHECK: %[[VAL_10:.*]] = fir.shape %[[C100_1]] : (index) -> !fir.shape<1>
174 // CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]](%[[VAL_10]]) typeparams %[[C20]] {uniq_name = "_QFmax2Ec3"} : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>)
175 // CHECK: %[[C1:.*]] = arith.constant 1 : index
176 // CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[C1]]) typeparams %[[C1]]0 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
177 // CHECK: %[[C1_2:.*]] = arith.constant 1 : index
178 // CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[C1_2]]) typeparams %[[C20]] : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, index, index) -> !fir.ref<!fir.char<1,20>>
179 // CHECK: %[[VAL_14:.*]] = arith.cmpi uge, %[[C10]], %[[C20]] : index
180 // CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[C10]], %[[C20]] : index
181 // CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<i8>
182 // CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
183 // CHECK: %[[VAL_18:.*]] = fir.convert %[[C20]] : (index) -> i64
184 // CHECK: %[[VAL_19:.*]] = fir.convert %[[C10]] : (index) -> i64
185 // CHECK: %[[VAL_20:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_16]], %[[VAL_17]], %[[VAL_18]], %[[VAL_19]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
186 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
187 // CHECK: %[[VAL_21:.*]] = arith.cmpi sgt, %[[VAL_20]], %[[C0_I32]] : i32
188 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,?>>
189 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<!fir.char<1,?>>
190 // CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_21]], %[[VAL_23]], %[[VAL_22]] : !fir.ref<!fir.char<1,?>>
191 // CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_21]], %[[C20]], %[[C10]] : index
192 // CHECK: %[[VAL_26:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_15]] : index) {bindc_name = ".chrtmp"}
193 // CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_15]], %[[VAL_25]] : index
194 // CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_15]], %[[VAL_25]] : index
195 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
196 // CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (index) -> i64
197 // CHECK: %[[VAL_30:.*]] = arith.muli %[[C1_I64]], %[[VAL_29]] : i64
198 // CHECK: %[[FALSE:.*]] = arith.constant false
199 // CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
200 // CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
201 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_31]], %[[VAL_32]], %[[VAL_30]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
202 // CHECK: %[[C1_3:.*]] = arith.constant 1 : index
203 // CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_15]], %[[C1_3]] : index
204 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
205 // CHECK: %[[VAL_34:.*]] = fir.undefined !fir.char<1>
206 // CHECK: %[[VAL_35:.*]] = fir.insert_value %[[VAL_34]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
207 // CHECK: %[[C1_4:.*]] = arith.constant 1 : index
208 // CHECK: fir.do_loop %[[ARG3:.*]] = %[[VAL_28:.*]] to %[[VAL_33]] step %[[C1_4]] {
209 // CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
210 // CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[ARG3]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
211 // CHECK: fir.store %[[VAL_35:.*]] to %[[VAL_43]] : !fir.ref<!fir.char<1>>
213 // CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,20>>
214 // CHECK: %[[VAL_37:.*]]:2 = hlfir.declare %[[VAL_36]] typeparams %[[VAL_15]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,20>>, index) -> (!fir.ref<!fir.char<1,20>>, !fir.ref<!fir.char<1,20>>)
215 // CHECK: %[[FALSE_5:.*]] = arith.constant false
216 // CHECK: %[[VAL_38:.*]] = fir.undefined tuple<!fir.ref<!fir.char<1,20>>, i1>
217 // CHECK: %[[VAL_39:.*]] = fir.insert_value %[[VAL_38]], %[[FALSE_5]], [1 : index] : (tuple<!fir.ref<!fir.char<1,20>>, i1>, i1) -> tuple<!fir.ref<!fir.char<1,20>>, i1>
218 // CHECK: %[[VAL_40:.*]] = fir.insert_value %[[VAL_39]], %[[VAL_37]]#0, [0 : index] : (tuple<!fir.ref<!fir.char<1,20>>, i1>, !fir.ref<!fir.char<1,20>>) -> tuple<!fir.ref<!fir.char<1,20>>, i1>
219 // CHECK: %[[C1_6:.*]] = arith.constant 1 : index
220 // CHECK: %[[VAL_41:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[C1_6]]) typeparams %[[VAL_0]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
221 // CHECK: hlfir.assign %[[VAL_37]]#0 to %[[VAL_41:.*]] : !fir.ref<!fir.char<1,20>>, !fir.boxchar<1>
225 func.func @_QPmin2(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
226 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
227 %1 = fir.convert %0#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>>
228 %c100 = arith.constant 100 : index
229 %2 = fir.shape %c100 : (index) -> !fir.shape<1>
230 %3:2 = hlfir.declare %1(%2) typeparams %0#1 {uniq_name = "_QFmin2Ec1"} : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<100x!fir.char<1,?>>>, !fir.ref<!fir.array<100x!fir.char<1,?>>>)
231 %4:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
232 %c10 = arith.constant 10 : index
233 %5 = fir.convert %4#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,10>>>
234 %c100_0 = arith.constant 100 : index
235 %6 = fir.shape %c100_0 : (index) -> !fir.shape<1>
236 %7:2 = hlfir.declare %5(%6) typeparams %c10 {uniq_name = "_QFmin2Ec2"} : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,10>>>)
237 %8:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
238 %c20 = arith.constant 20 : index
239 %9 = fir.convert %8#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,20>>>
240 %c100_1 = arith.constant 100 : index
241 %10 = fir.shape %c100_1 : (index) -> !fir.shape<1>
242 %11:2 = hlfir.declare %9(%10) typeparams %c20 {uniq_name = "_QFmin2Ec3"} : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>)
243 %c1 = arith.constant 1 : index
244 %12 = hlfir.designate %7#0 (%c1) typeparams %c10 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
245 %c1_2 = arith.constant 1 : index
246 %13 = hlfir.designate %11#0 (%c1_2) typeparams %c20 : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, index, index) -> !fir.ref<!fir.char<1,20>>
247 %14 = hlfir.char_extremum min, %12, %13 : (!fir.ref<!fir.char<1,10>>, !fir.ref<!fir.char<1,20>>) -> !hlfir.expr<!fir.char<1,20>>
248 %c1_3 = arith.constant 1 : index
249 %15 = hlfir.designate %3#0 (%c1_3) typeparams %0#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
250 hlfir.assign %14 to %15 : !hlfir.expr<!fir.char<1,20>>, !fir.boxchar<1>
251 hlfir.destroy %14 : !hlfir.expr<!fir.char<1,20>>
255 // CHECK: func.func @_QPmin2(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}) {
256 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
257 // CHECK: %[[VAL_1:.*]] = fir.convert %[[VAL_0]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,?>>>
258 // CHECK: %[[C100:.*]] = arith.constant 100 : index
259 // CHECK: %[[VAL_2:.*]] = fir.shape %[[C100]] : (index) -> !fir.shape<1>
260 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_1]](%[[VAL_2]]) typeparams %[[VAL_0]]#1 {uniq_name = "_QFmin2Ec1"} : (!fir.ref<!fir.array<100x!fir.char<1,?>>>, !fir.shape<1>, index) -> (!fir.box<!fir.array<100x!fir.char<1,?>>>, !fir.ref<!fir.array<100x!fir.char<1,?>>>)
261 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
262 // CHECK: %[[C10:.*]] = arith.constant 10 : index
263 // CHECK: %[[VAL_5:.*]] = fir.convert %[[VAL_4]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,10>>>
264 // CHECK: %[[C100_0:.*]] = arith.constant 100 : index
265 // CHECK: %[[VAL_6:.*]] = fir.shape %[[C100_0]] : (index) -> !fir.shape<1>
266 // CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_5]](%[[VAL_6]]) typeparams %[[C10]] {uniq_name = "_QFmin2Ec2"} : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,10>>>, !fir.ref<!fir.array<100x!fir.char<1,10>>>)
267 // CHECK: %[[VAL_8:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
268 // CHECK: %[[C20:.*]] = arith.constant 20 : index
269 // CHECK: %[[VAL_9:.*]] = fir.convert %[[VAL_8]]#0 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<100x!fir.char<1,20>>>
270 // CHECK: %[[C100_1:.*]] = arith.constant 100 : index
271 // CHECK: %[[VAL_10:.*]] = fir.shape %[[C100_1]] : (index) -> !fir.shape<1>
272 // CHECK: %[[VAL_11:.*]]:2 = hlfir.declare %[[VAL_9]](%[[VAL_10]]) typeparams %[[C20]] {uniq_name = "_QFmin2Ec3"} : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.shape<1>, index) -> (!fir.ref<!fir.array<100x!fir.char<1,20>>>, !fir.ref<!fir.array<100x!fir.char<1,20>>>)
273 // CHECK: %[[C1:.*]] = arith.constant 1 : index
274 // CHECK: %[[VAL_12:.*]] = hlfir.designate %[[VAL_7]]#0 (%[[C1]]) typeparams %[[C1]]0 : (!fir.ref<!fir.array<100x!fir.char<1,10>>>, index, index) -> !fir.ref<!fir.char<1,10>>
275 // CHECK: %[[C1_2:.*]] = arith.constant 1 : index
276 // CHECK: %[[VAL_13:.*]] = hlfir.designate %[[VAL_11]]#0 (%[[C1_2]]) typeparams %[[C20]] : (!fir.ref<!fir.array<100x!fir.char<1,20>>>, index, index) -> !fir.ref<!fir.char<1,20>>
277 // CHECK: %[[VAL_14:.*]] = arith.cmpi uge, %[[C10]], %[[C20]] : index
278 // CHECK: %[[VAL_15:.*]] = arith.select %[[VAL_14]], %[[C10]], %[[C20]] : index
279 // CHECK: %[[VAL_16:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<i8>
280 // CHECK: %[[VAL_17:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<i8>
281 // CHECK: %[[VAL_18:.*]] = fir.convert %[[C20]] : (index) -> i64
282 // CHECK: %[[VAL_19:.*]] = fir.convert %[[C10]] : (index) -> i64
283 // CHECK: %[[VAL_20:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_16]], %[[VAL_17]], %[[VAL_18]], %[[VAL_19]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
284 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
285 // CHECK: %[[VAL_21:.*]] = arith.cmpi slt, %[[VAL_20]], %[[C0_I32]] : i32
286 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_12]] : (!fir.ref<!fir.char<1,10>>) -> !fir.ref<!fir.char<1,?>>
287 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_13]] : (!fir.ref<!fir.char<1,20>>) -> !fir.ref<!fir.char<1,?>>
288 // CHECK: %[[VAL_24:.*]] = arith.select %[[VAL_21]], %[[VAL_23]], %[[VAL_22]] : !fir.ref<!fir.char<1,?>>
289 // CHECK: %[[VAL_25:.*]] = arith.select %[[VAL_21]], %[[C20]], %[[C10]] : index
290 // CHECK: %[[VAL_26:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_15]] : index) {bindc_name = ".chrtmp"}
291 // CHECK: %[[VAL_27:.*]] = arith.cmpi slt, %[[VAL_15]], %[[VAL_25]] : index
292 // CHECK: %[[VAL_28:.*]] = arith.select %[[VAL_27]], %[[VAL_15]], %[[VAL_25]] : index
293 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
294 // CHECK: %[[VAL_29:.*]] = fir.convert %[[VAL_28]] : (index) -> i64
295 // CHECK: %[[VAL_30:.*]] = arith.muli %[[C1_I64]], %[[VAL_29]] : i64
296 // CHECK: %[[FALSE:.*]] = arith.constant false
297 // CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
298 // CHECK: %[[VAL_32:.*]] = fir.convert %[[VAL_24]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
299 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_31]], %[[VAL_32]], %[[VAL_30]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
300 // CHECK: %[[C1_3:.*]] = arith.constant 1 : index
301 // CHECK: %[[VAL_33:.*]] = arith.subi %[[VAL_15]], %[[C1_3]] : index
302 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
303 // CHECK: %[[VAL_34:.*]] = fir.undefined !fir.char<1>
304 // CHECK: %[[VAL_35:.*]] = fir.insert_value %[[VAL_34]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
305 // CHECK: %[[C1_4:.*]] = arith.constant 1 : index
306 // CHECK: fir.do_loop %[[ARG3:.*]] = %[[VAL_28:.*]] to %[[VAL_33]] step %[[C1_4]] {
307 // CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
308 // CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[ARG3]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
309 // CHECK: fir.store %[[VAL_35:.*]] to %[[VAL_43]] : !fir.ref<!fir.char<1>>
311 // CHECK: %[[VAL_36:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,20>>
312 // CHECK: %[[VAL_37:.*]]:2 = hlfir.declare %[[VAL_36]] typeparams %[[VAL_15]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,20>>, index) -> (!fir.ref<!fir.char<1,20>>, !fir.ref<!fir.char<1,20>>)
313 // CHECK: %[[FALSE_5:.*]] = arith.constant false
314 // CHECK: %[[VAL_38:.*]] = fir.undefined tuple<!fir.ref<!fir.char<1,20>>, i1>
315 // CHECK: %[[VAL_39:.*]] = fir.insert_value %[[VAL_38]], %[[FALSE_5]], [1 : index] : (tuple<!fir.ref<!fir.char<1,20>>, i1>, i1) -> tuple<!fir.ref<!fir.char<1,20>>, i1>
316 // CHECK: %[[VAL_40:.*]] = fir.insert_value %[[VAL_39]], %[[VAL_37]]#0, [0 : index] : (tuple<!fir.ref<!fir.char<1,20>>, i1>, !fir.ref<!fir.char<1,20>>) -> tuple<!fir.ref<!fir.char<1,20>>, i1>
317 // CHECK: %[[C1_6:.*]] = arith.constant 1 : index
318 // CHECK: %[[VAL_41:.*]] = hlfir.designate %[[VAL_3]]#0 (%[[C1_6]]) typeparams %[[VAL_0]]#1 : (!fir.box<!fir.array<100x!fir.char<1,?>>>, index, index) -> !fir.boxchar<1>
319 // CHECK: hlfir.assign %[[VAL_37]]#0 to %[[VAL_41:.*]] : !fir.ref<!fir.char<1,20>>, !fir.boxchar<1>
323 func.func @_QPmax3(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}, %arg3: !fir.boxchar<1> {fir.bindc_name = "c4"}) {
324 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
325 %1:2 = hlfir.declare %0#0 typeparams %0#1 {uniq_name = "_QFmax3Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
326 %2:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
327 %3:2 = hlfir.declare %2#0 typeparams %2#1 {uniq_name = "_QFmax3Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
328 %4:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
329 %5:2 = hlfir.declare %4#0 typeparams %4#1 {uniq_name = "_QFmax3Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
330 %6:2 = fir.unboxchar %arg3 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
331 %7:2 = hlfir.declare %6#0 typeparams %6#1 {uniq_name = "_QFmax3Ec4"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
332 %8 = hlfir.char_extremum max, %3#0, %5#0, %7#0 : (!fir.boxchar<1>, !fir.boxchar<1>, !fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
333 hlfir.assign %8 to %1#0 : !hlfir.expr<!fir.char<1,?>>, !fir.boxchar<1>
334 hlfir.destroy %8 : !hlfir.expr<!fir.char<1,?>>
338 // CHECK: func.func @_QPmax3(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}, %[[ARG3:.*]]: !fir.boxchar<1> {fir.bindc_name = "c4"}) {
339 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
340 // CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]]#0 typeparams %[[VAL_0]]#1 {uniq_name = "_QFmax3Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
341 // CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
342 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]#0 typeparams %[[VAL_2]]#1 {uniq_name = "_QFmax3Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
343 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
344 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFmax3Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
345 // CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[ARG3]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
346 // CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]]#0 typeparams %[[VAL_6]]#1 {uniq_name = "_QFmax3Ec4"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
347 // CHECK: %[[VAL_8:.*]] = arith.cmpi uge, %[[VAL_2]]#1, %[[VAL_4]]#1 : index
348 // CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_8]], %[[VAL_2]]#1, %[[VAL_4]]#1 : index
349 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_5]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
350 // CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
351 // CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
352 // CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
353 // CHECK: %[[VAL_14:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_10]], %[[VAL_11]], %[[VAL_12]], %[[VAL_13]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
354 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
355 // CHECK: %[[VAL_15:.*]] = arith.cmpi sgt, %[[VAL_14]], %[[C0_I32]] : i32
356 // CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_5]]#1, %[[VAL_3]]#1 : !fir.ref<!fir.char<1,?>>
357 // CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_15]], %[[VAL_4]]#1, %[[VAL_2]]#1 : index
358 // CHECK: %[[VAL_18:.*]] = arith.cmpi uge, %[[VAL_9]], %[[VAL_6]]#1 : index
359 // CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_9]], %[[VAL_6]]#1 : index
360 // CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_7]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
361 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
362 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i64
363 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
364 // CHECK: %[[VAL_24:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_20]], %[[VAL_21]], %[[VAL_22]], %[[VAL_23]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
365 // CHECK: %[[C0_I32_0:.*]] = arith.constant 0 : i32
366 // CHECK: %[[VAL_25:.*]] = arith.cmpi sgt, %[[VAL_24]], %[[C0_I32_0]] : i32
367 // CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_7]]#1, %[[VAL_16]] : !fir.ref<!fir.char<1,?>>
368 // CHECK: %[[VAL_27:.*]] = arith.select %[[VAL_25]], %[[VAL_6]]#1, %[[VAL_17]] : index
369 // CHECK: %[[VAL_28:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_19]] : index) {bindc_name = ".chrtmp"}
370 // CHECK: %[[VAL_29:.*]] = arith.cmpi slt, %[[VAL_19]], %[[VAL_27]] : index
371 // CHECK: %[[VAL_30:.*]] = arith.select %[[VAL_29]], %[[VAL_19]], %[[VAL_27]] : index
372 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
373 // CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30]] : (index) -> i64
374 // CHECK: %[[VAL_32:.*]] = arith.muli %[[C1_I64]], %[[VAL_31]] : i64
375 // CHECK: %[[FALSE:.*]] = arith.constant false
376 // CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
377 // CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
378 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_33]], %[[VAL_34]], %[[VAL_32]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
379 // CHECK: %[[C1:.*]] = arith.constant 1 : index
380 // CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_19]], %[[C1]] : index
381 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
382 // CHECK: %[[VAL_36:.*]] = fir.undefined !fir.char<1>
383 // CHECK: %[[VAL_37:.*]] = fir.insert_value %[[VAL_36]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
384 // CHECK: %[[C1_1:.*]] = arith.constant 1 : index
385 // CHECK: fir.do_loop %[[ARG4:.*]] = %[[VAL_30:.*]] to %[[VAL_35]] step %[[C1_1]] {
386 // CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
387 // CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[ARG4]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
388 // CHECK: fir.store %[[VAL_37:.*]] to %[[VAL_43]] : !fir.ref<!fir.char<1>>
390 // CHECK: %[[VAL_38:.*]]:2 = hlfir.declare %[[VAL_28]] typeparams %[[VAL_19]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
391 // CHECK: %[[FALSE_2:.*]] = arith.constant false
392 // CHECK: %[[VAL_39:.*]] = fir.undefined tuple<!fir.boxchar<1>, i1>
393 // CHECK: %[[VAL_40:.*]] = fir.insert_value %[[VAL_39]], %[[FALSE_2]], [1 : index] : (tuple<!fir.boxchar<1>, i1>, i1) -> tuple<!fir.boxchar<1>, i1>
394 // CHECK: %[[VAL_41:.*]] = fir.insert_value %[[VAL_40]], %[[VAL_38]]#0, [0 : index] : (tuple<!fir.boxchar<1>, i1>, !fir.boxchar<1>) -> tuple<!fir.boxchar<1>, i1>
395 // CHECK: hlfir.assign %[[VAL_38]]#0 to %[[VAL_1]]#0 : !fir.boxchar<1>, !fir.boxchar<1>
399 func.func @_QPmin3(%arg0: !fir.boxchar<1> {fir.bindc_name = "c1"}, %arg1: !fir.boxchar<1> {fir.bindc_name = "c2"}, %arg2: !fir.boxchar<1> {fir.bindc_name = "c3"}, %arg3: !fir.boxchar<1> {fir.bindc_name = "c4"}) {
400 %0:2 = fir.unboxchar %arg0 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
401 %1:2 = hlfir.declare %0#0 typeparams %0#1 {uniq_name = "_QFmin3Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
402 %2:2 = fir.unboxchar %arg1 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
403 %3:2 = hlfir.declare %2#0 typeparams %2#1 {uniq_name = "_QFmin3Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
404 %4:2 = fir.unboxchar %arg2 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
405 %5:2 = hlfir.declare %4#0 typeparams %4#1 {uniq_name = "_QFmin3Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
406 %6:2 = fir.unboxchar %arg3 : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
407 %7:2 = hlfir.declare %6#0 typeparams %6#1 {uniq_name = "_QFmin3Ec4"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
408 %8 = hlfir.char_extremum min, %3#0, %5#0, %7#0 : (!fir.boxchar<1>, !fir.boxchar<1>, !fir.boxchar<1>) -> !hlfir.expr<!fir.char<1,?>>
409 hlfir.assign %8 to %1#0 : !hlfir.expr<!fir.char<1,?>>, !fir.boxchar<1>
410 hlfir.destroy %8 : !hlfir.expr<!fir.char<1,?>>
414 // CHECK: func.func @_QPmin3(%[[ARG0:.*]]: !fir.boxchar<1> {fir.bindc_name = "c1"}, %[[ARG1:.*]]: !fir.boxchar<1> {fir.bindc_name = "c2"}, %[[ARG2:.*]]: !fir.boxchar<1> {fir.bindc_name = "c3"}, %[[ARG3:.*]]: !fir.boxchar<1> {fir.bindc_name = "c4"}) {
415 // CHECK: %[[VAL_0:.*]]:2 = fir.unboxchar %[[ARG0]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
416 // CHECK: %[[VAL_1:.*]]:2 = hlfir.declare %[[VAL_0]]#0 typeparams %[[VAL_0]]#1 {uniq_name = "_QFmin3Ec1"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
417 // CHECK: %[[VAL_2:.*]]:2 = fir.unboxchar %[[ARG1]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
418 // CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_2]]#0 typeparams %[[VAL_2]]#1 {uniq_name = "_QFmin3Ec2"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
419 // CHECK: %[[VAL_4:.*]]:2 = fir.unboxchar %[[ARG2]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
420 // CHECK: %[[VAL_5:.*]]:2 = hlfir.declare %[[VAL_4]]#0 typeparams %[[VAL_4]]#1 {uniq_name = "_QFmin3Ec3"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
421 // CHECK: %[[VAL_6:.*]]:2 = fir.unboxchar %[[ARG3]] : (!fir.boxchar<1>) -> (!fir.ref<!fir.char<1,?>>, index)
422 // CHECK: %[[VAL_7:.*]]:2 = hlfir.declare %[[VAL_6]]#0 typeparams %[[VAL_6]]#1 {uniq_name = "_QFmin3Ec4"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
423 // CHECK: %[[VAL_8:.*]] = arith.cmpi uge, %[[VAL_2]]#1, %[[VAL_4]]#1 : index
424 // CHECK: %[[VAL_9:.*]] = arith.select %[[VAL_8]], %[[VAL_2]]#1, %[[VAL_4]]#1 : index
425 // CHECK: %[[VAL_10:.*]] = fir.convert %[[VAL_5]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
426 // CHECK: %[[VAL_11:.*]] = fir.convert %[[VAL_3]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
427 // CHECK: %[[VAL_12:.*]] = fir.convert %[[VAL_4]]#1 : (index) -> i64
428 // CHECK: %[[VAL_13:.*]] = fir.convert %[[VAL_2]]#1 : (index) -> i64
429 // CHECK: %[[VAL_14:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_10]], %[[VAL_11]], %[[VAL_12]], %[[VAL_13]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
430 // CHECK: %[[C0_I32:.*]] = arith.constant 0 : i32
431 // CHECK: %[[VAL_15:.*]] = arith.cmpi slt, %[[VAL_14]], %[[C0_I32]] : i32
432 // CHECK: %[[VAL_16:.*]] = arith.select %[[VAL_15]], %[[VAL_5]]#1, %[[VAL_3]]#1 : !fir.ref<!fir.char<1,?>>
433 // CHECK: %[[VAL_17:.*]] = arith.select %[[VAL_15]], %[[VAL_4]]#1, %[[VAL_2]]#1 : index
434 // CHECK: %[[VAL_18:.*]] = arith.cmpi uge, %[[VAL_9]], %[[VAL_6]]#1 : index
435 // CHECK: %[[VAL_19:.*]] = arith.select %[[VAL_18]], %[[VAL_9]], %[[VAL_6]]#1 : index
436 // CHECK: %[[VAL_20:.*]] = fir.convert %[[VAL_7]]#1 : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
437 // CHECK: %[[VAL_21:.*]] = fir.convert %[[VAL_16]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
438 // CHECK: %[[VAL_22:.*]] = fir.convert %[[VAL_6]]#1 : (index) -> i64
439 // CHECK: %[[VAL_23:.*]] = fir.convert %[[VAL_17]] : (index) -> i64
440 // CHECK: %[[VAL_24:.*]] = fir.call @_FortranACharacterCompareScalar1(%[[VAL_20]], %[[VAL_21]], %[[VAL_22]], %[[VAL_23]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i64) -> i32
441 // CHECK: %[[C0_I32_0:.*]] = arith.constant 0 : i32
442 // CHECK: %[[VAL_25:.*]] = arith.cmpi slt, %[[VAL_24]], %[[C0_I32_0]] : i32
443 // CHECK: %[[VAL_26:.*]] = arith.select %[[VAL_25]], %[[VAL_7]]#1, %[[VAL_16]] : !fir.ref<!fir.char<1,?>>
444 // CHECK: %[[VAL_27:.*]] = arith.select %[[VAL_25]], %[[VAL_6]]#1, %[[VAL_17]] : index
445 // CHECK: %[[VAL_28:.*]] = fir.alloca !fir.char<1,?>(%[[VAL_19]] : index) {bindc_name = ".chrtmp"}
446 // CHECK: %[[VAL_29:.*]] = arith.cmpi slt, %[[VAL_19]], %[[VAL_27]] : index
447 // CHECK: %[[VAL_30:.*]] = arith.select %[[VAL_29]], %[[VAL_19]], %[[VAL_27]] : index
448 // CHECK: %[[C1_I64:.*]] = arith.constant 1 : i64
449 // CHECK: %[[VAL_31:.*]] = fir.convert %[[VAL_30]] : (index) -> i64
450 // CHECK: %[[VAL_32:.*]] = arith.muli %[[C1_I64]], %[[VAL_31]] : i64
451 // CHECK: %[[FALSE:.*]] = arith.constant false
452 // CHECK: %[[VAL_33:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
453 // CHECK: %[[VAL_34:.*]] = fir.convert %[[VAL_26]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<i8>
454 // CHECK: fir.call @llvm.memmove.p0.p0.i64(%[[VAL_33]], %[[VAL_34]], %[[VAL_32]], %[[FALSE]]) : (!fir.ref<i8>, !fir.ref<i8>, i64, i1) -> ()
455 // CHECK: %[[C1:.*]] = arith.constant 1 : index
456 // CHECK: %[[VAL_35:.*]] = arith.subi %[[VAL_19]], %[[C1]] : index
457 // CHECK: %[[C32_I8:.*]] = arith.constant 32 : i8
458 // CHECK: %[[VAL_36:.*]] = fir.undefined !fir.char<1>
459 // CHECK: %[[VAL_37:.*]] = fir.insert_value %[[VAL_36]], %[[C32_I8]], [0 : index] : (!fir.char<1>, i8) -> !fir.char<1>
460 // CHECK: %[[C1_1:.*]] = arith.constant 1 : index
461 // CHECK: fir.do_loop %[[ARG4:.*]] = %[[VAL_30:.*]] to %[[VAL_35]] step %[[C1_1]] {
462 // CHECK: %[[VAL_42:.*]] = fir.convert %[[VAL_28]] : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.array<?x!fir.char<1>>>
463 // CHECK: %[[VAL_43:.*]] = fir.coordinate_of %[[VAL_42]], %[[ARG4]] : (!fir.ref<!fir.array<?x!fir.char<1>>>, index) -> !fir.ref<!fir.char<1>>
464 // CHECK: fir.store %[[VAL_37:.*]] to %[[VAL_43]] : !fir.ref<!fir.char<1>>
466 // CHECK: %[[VAL_38:.*]]:2 = hlfir.declare %[[VAL_28]] typeparams %[[VAL_19]] {uniq_name = ".tmp.char_extremum"} : (!fir.ref<!fir.char<1,?>>, index) -> (!fir.boxchar<1>, !fir.ref<!fir.char<1,?>>)
467 // CHECK: %[[FALSE_2:.*]] = arith.constant false
468 // CHECK: %[[VAL_39:.*]] = fir.undefined tuple<!fir.boxchar<1>, i1>
469 // CHECK: %[[VAL_40:.*]] = fir.insert_value %[[VAL_39]], %[[FALSE_2]], [1 : index] : (tuple<!fir.boxchar<1>, i1>, i1) -> tuple<!fir.boxchar<1>, i1>
470 // CHECK: %[[VAL_41:.*]] = fir.insert_value %[[VAL_40]], %[[VAL_38]]#0, [0 : index] : (tuple<!fir.boxchar<1>, i1>, !fir.boxchar<1>) -> tuple<!fir.boxchar<1>, i1>
471 // CHECK: hlfir.assign %[[VAL_38]]#0 to %[[VAL_1]]#0 : !fir.boxchar<1>, !fir.boxchar<1>