summaryrefslogtreecommitdiff
path: root/flang/test/HLFIR/shapeof.fir
diff options
context:
space:
mode:
Diffstat (limited to 'flang/test/HLFIR/shapeof.fir')
-rw-r--r--flang/test/HLFIR/shapeof.fir18
1 files changed, 18 insertions, 0 deletions
diff --git a/flang/test/HLFIR/shapeof.fir b/flang/test/HLFIR/shapeof.fir
index b91efc276b62..43e22dd320c1 100644
--- a/flang/test/HLFIR/shapeof.fir
+++ b/flang/test/HLFIR/shapeof.fir
@@ -27,3 +27,21 @@ func.func @shapeof2(%arg0: !hlfir.expr<?x2xi32>) -> !fir.shape<2> {
// CHECK-ALL: %[[EXPR:.*]]: !hlfir.expr<?x2xi32>
// CHECK-ALL-NEXT: %[[SHAPE:.*]] = hlfir.shape_of %[[EXPR]] : (!hlfir.expr<?x2xi32>) -> !fir.shape<2>
// CHECK-ALL-NEXT: return %[[SHAPE]]
+
+// Checks hlfir.elemental -> hlfir.shape_of folding
+func.func @shapeof_fold1(%extent: index) -> !fir.shape<1> {
+ %shape1 = fir.shape %extent : (index) -> !fir.shape<1>
+ %elem = hlfir.elemental %shape1 : (!fir.shape<1>) -> !hlfir.expr<?xindex> {
+ hlfir.yield_element %extent : index
+ }
+ %shape2 = hlfir.shape_of %elem : (!hlfir.expr<?xindex>) -> !fir.shape<1>
+ return %shape2 : !fir.shape<1>
+}
+// CHECK-ALL-LABEL: func.func @shapeof_fold1(
+// CHECK-ALL-SAME: %[[VAL_0:.*]]: index) -> !fir.shape<1> {
+// CHECK-CANON-NEXT: %[[VAL_1:.*]] = fir.shape %[[VAL_0]] : (index) -> !fir.shape<1>
+// CHECK-CANON-NEXT: %[[VAL_2:.*]] = hlfir.elemental %[[VAL_1]] : (!fir.shape<1>) -> !hlfir.expr<?xindex> {
+// CHECK-CANON-NEXT: hlfir.yield_element %[[VAL_0]] : index
+// CHECK-CANON-NEXT: }
+// CHECK-CANON-NEXT: return %[[VAL_1]] : !fir.shape<1>
+// CHECK-CANON-NEXT: }