llvm-project
40 строк · 1.7 Кб
1// Test rewrite of fir.declare. The result is replaced by the memref operand.
2// RUN: fir-opt --cg-rewrite="preserve-declare=true" %s -o - | FileCheck %s --check-prefixes DECL
3// RUN: fir-opt --cg-rewrite="preserve-declare=false" %s -o - | FileCheck %s --check-prefixes NODECL
4// RUN: fir-opt --cg-rewrite %s -o - | FileCheck %s --check-prefixes NODECL
5
6
7func.func @test(%arg0: !fir.ref<!fir.array<12x23xi32>>) {
8%c-1 = arith.constant -1 : index
9%c12 = arith.constant 12 : index
10%c-2 = arith.constant -2 : index
11%c23 = arith.constant 23 : index
12%0 = fir.shape_shift %c12, %c-1, %c23, %c-2 : (index, index, index, index) -> !fir.shapeshift<2>
13%1 = fir.declare %arg0(%0) {uniq_name = "_QFarray_numeric_lboundsEx"} : (!fir.ref<!fir.array<12x23xi32>>, !fir.shapeshift<2>) -> !fir.ref<!fir.array<12x23xi32>>
14fir.call @bar(%1) : (!fir.ref<!fir.array<12x23xi32>>) -> ()
15return
16}
17func.func private @bar(%arg0: !fir.ref<!fir.array<12x23xi32>>)
18
19
20// NODECL-LABEL: func.func @test(
21// NODECL-SAME: %[[arg0:.*]]: !fir.ref<!fir.array<12x23xi32>>) {
22// NODECL-NEXT: fir.call @bar(%[[arg0]]) : (!fir.ref<!fir.array<12x23xi32>>) -> ()
23
24// DECL-LABEL: func.func @test(
25// DECL-SAME: %[[arg0:.*]]: !fir.ref<!fir.array<12x23xi32>>) {
26// DECL: fircg.ext_declare
27
28
29func.func @useless_shape_with_duplicate_extent_operand(%arg0: !fir.ref<!fir.array<3x3xf32>>) {
30%c3 = arith.constant 3 : index
31%1 = fir.shape %c3, %c3 : (index, index) -> !fir.shape<2>
32%2 = fir.declare %arg0(%1) {uniq_name = "u"} : (!fir.ref<!fir.array<3x3xf32>>, !fir.shape<2>) -> !fir.ref<!fir.array<3x3xf32>>
33return
34}
35
36// NODECL-LABEL: func.func @useless_shape_with_duplicate_extent_operand(
37// NODECL-NEXT: return
38
39// DECL-LABEL: func.func @useless_shape_with_duplicate_extent_operand(
40// DECL: fircg.ext_declare
41