[LLVM] Fix Maintainers.md formatting (NFC)
[llvm-project.git] / flang / test / HLFIR / shapeof.fir
blobb91efc276b62e27fa71400d8403dcaa2b529bb75
1 // Test hlfir.shape_of operation parse, verify (no errors), and unparse
2 // RUN: fir-opt %s | fir-opt | FileCheck --check-prefix CHECK --check-prefix CHECK-ALL %s
4 // Test canonicalization
5 // RUN: fir-opt %s --canonicalize | FileCheck --check-prefix CHECK-CANON --check-prefix CHECK-ALL %s
7 func.func @shapeof(%arg0: !hlfir.expr<2x2xi32>) -> !fir.shape<2> {
8   %shape = hlfir.shape_of %arg0 : (!hlfir.expr<2x2xi32>) -> !fir.shape<2>
9   return %shape : !fir.shape<2>
11 // CHECK-ALL-LABEL: func.func @shapeof
12 // CHECK-ALL:          %[[EXPR:.*]]: !hlfir.expr<2x2xi32>
14 // CHECK-NEXT:       %[[SHAPE:.*]] = hlfir.shape_of %[[EXPR]] : (!hlfir.expr<2x2xi32>) -> !fir.shape<2>
16 // CHECK-CANON-NEXT: %[[C2:.*]] = arith.constant 2 : index
17 // CHECK-CANON-NEXT: %[[SHAPE:.*]] = fir.shape %[[C2]], %[[C2]] : (index, index) -> !fir.shape<2>
19 // CHECK-ALL-NEXT:   return %[[SHAPE]]
21 // no canonicalization of expressions with unknown extents
22 func.func @shapeof2(%arg0: !hlfir.expr<?x2xi32>) -> !fir.shape<2> {
23   %shape = hlfir.shape_of %arg0 : (!hlfir.expr<?x2xi32>) -> !fir.shape<2>
24   return %shape : !fir.shape<2>
26 // CHECK-ALL-LABEL: func.func @shapeof2
27 // CHECK-ALL:          %[[EXPR:.*]]: !hlfir.expr<?x2xi32>
28 // CHECK-ALL-NEXT:   %[[SHAPE:.*]] = hlfir.shape_of %[[EXPR]] : (!hlfir.expr<?x2xi32>) -> !fir.shape<2>
29 // CHECK-ALL-NEXT:   return %[[SHAPE]]