// RUN: fir-opt %s --split-input-file --pass-pipeline="builtin.module(test-acc-recipe-populate{recipe-type=firstprivate})" | FileCheck %s // The tests here use a synthetic hlfir.declare in order to ensure that the hlfir dialect is // loaded. This is required because the pass used is part of OpenACC test passes outside of // flang and the APIs being test may generate hlfir even when it does not appear. // Test scalar type (f32) // CHECK: acc.firstprivate.recipe @firstprivate_scalar : !fir.ref init { // CHECK: ^bb0(%{{.*}}: !fir.ref): // CHECK: %[[ALLOC:.*]] = fir.alloca f32 // CHECK: acc.yield %[[ALLOC]] : !fir.ref // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref, %[[DST:.*]]: !fir.ref): // CHECK: %[[LOAD:.*]] = fir.load %[[SRC]] : !fir.ref // CHECK: hlfir.assign %[[LOAD]] to %[[DST]] temporary_lhs : f32, !fir.ref // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_scalar() { %0 = fir.alloca f32 {test.var = "scalar"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test integer scalar // CHECK: acc.firstprivate.recipe @firstprivate_int : !fir.ref init { // CHECK: ^bb0(%{{.*}}: !fir.ref): // CHECK: %[[ALLOC:.*]] = fir.alloca i32 // CHECK: acc.yield %[[ALLOC]] : !fir.ref // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref, %[[DST:.*]]: !fir.ref): // CHECK: %[[LOAD:.*]] = fir.load %[[SRC]] : !fir.ref // CHECK: hlfir.assign %[[LOAD]] to %[[DST]] temporary_lhs : i32, !fir.ref // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_int() { %0 = fir.alloca i32 {test.var = "int"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test logical type // CHECK: acc.firstprivate.recipe @firstprivate_logical : !fir.ref> init { // CHECK: ^bb0(%{{.*}}: !fir.ref>): // CHECK: %[[ALLOC:.*]] = fir.alloca !fir.logical<4> // CHECK: acc.yield %[[ALLOC]] : !fir.ref> // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref>, %[[DST:.*]]: !fir.ref>): // CHECK: %[[LOAD:.*]] = fir.load %[[SRC]] : !fir.ref> // CHECK: hlfir.assign %[[LOAD]] to %[[DST]] temporary_lhs : !fir.logical<4>, !fir.ref> // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_logical() { %0 = fir.alloca !fir.logical<4> {test.var = "logical"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test complex type // CHECK: acc.firstprivate.recipe @firstprivate_complex : !fir.ref> init { // CHECK: ^bb0(%{{.*}}: !fir.ref>): // CHECK: %[[ALLOC:.*]] = fir.alloca complex // CHECK: acc.yield %[[ALLOC]] : !fir.ref> // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref>, %[[DST:.*]]: !fir.ref>): // CHECK: %[[LOAD:.*]] = fir.load %[[SRC]] : !fir.ref> // CHECK: hlfir.assign %[[LOAD]] to %[[DST]] temporary_lhs : complex, !fir.ref> // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_complex() { %0 = fir.alloca complex {test.var = "complex"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test 1D static array // CHECK: acc.firstprivate.recipe @firstprivate_array_1d : !fir.ref> init { // CHECK: ^bb0(%{{.*}}: !fir.ref>): // CHECK: %[[ALLOC:.*]] = fir.alloca !fir.array<100xf32> // CHECK: acc.yield %[[ALLOC]] : !fir.ref> // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref>, %[[DST:.*]]: !fir.ref>): // CHECK: hlfir.assign %[[SRC]] to %[[DST]] temporary_lhs : !fir.ref>, !fir.ref> // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_array_1d() { %0 = fir.alloca !fir.array<100xf32> {test.var = "array_1d"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test 2D static array // CHECK: acc.firstprivate.recipe @firstprivate_array_2d : !fir.ref> init { // CHECK: ^bb0(%{{.*}}: !fir.ref>): // CHECK: %[[ALLOC:.*]] = fir.alloca !fir.array<10x20xi32> // CHECK: acc.yield %[[ALLOC]] : !fir.ref> // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref>, %[[DST:.*]]: !fir.ref>): // CHECK: hlfir.assign %[[SRC]] to %[[DST]] temporary_lhs : !fir.ref>, !fir.ref> // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_array_2d() { %0 = fir.alloca !fir.array<10x20xi32> {test.var = "array_2d"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return } // ----- // Test derived type with multiple fields // CHECK: acc.firstprivate.recipe @firstprivate_derived : !fir.ref> init { // CHECK: ^bb0(%{{.*}}: !fir.ref>): // CHECK: %[[ALLOC:.*]] = fir.alloca !fir.type<_QTpoint{x:f32,y:f32,z:f32}> // CHECK: acc.yield %[[ALLOC]] : !fir.ref> // CHECK: } copy { // CHECK: ^bb0(%[[SRC:.*]]: !fir.ref>, %[[DST:.*]]: !fir.ref>): // CHECK: hlfir.assign %[[SRC]] to %[[DST]] temporary_lhs : !fir.ref>, !fir.ref> // CHECK: acc.terminator // CHECK: } // CHECK-NOT: destroy func.func @test_derived() { %0 = fir.alloca !fir.type<_QTpoint{x:f32,y:f32,z:f32}> {test.var = "derived"} %var = fir.alloca f32 %1:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) return }