|
| 1 | +!RUN: %flang_fc1 -fdebug-unparse-no-sema %s 2>&1 | FileCheck %s -check-prefix=UNPARSE |
| 2 | +!RUN: %flang_fc1 -fdebug-dump-parse-tree-no-sema %s 2>&1 | FileCheck %s -check-prefix=TREE |
| 3 | + |
| 4 | +subroutine test_prefetch_01(a, b) |
| 5 | + integer, intent(in) :: a |
| 6 | + integer, intent(inout) :: b(5) |
| 7 | + integer :: i = 2 |
| 8 | + integer :: res |
| 9 | + |
| 10 | +!TREE: | | DeclarationConstruct -> SpecificationConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> Name = 'a' |
| 11 | + |
| 12 | +!UNPARSE: !DIR$ PREFETCH a |
| 13 | + !dir$ prefetch a |
| 14 | + b(1) = a |
| 15 | + |
| 16 | +!TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> Name = 'b' |
| 17 | + |
| 18 | +!UNPARSE: !DIR$ PREFETCH b |
| 19 | + !dir$ prefetch b |
| 20 | + res = sum(b) |
| 21 | + |
| 22 | +!TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> Name = 'a' |
| 23 | +!TREE: | | Designator -> DataRef -> ArrayElement |
| 24 | +!TREE: | | | DataRef -> Name = 'b' |
| 25 | +!TREE: | | | SectionSubscript -> SubscriptTriplet |
| 26 | +!TREE: | | | | Scalar -> Integer -> Expr -> LiteralConstant -> IntLiteralConstant = '3' |
| 27 | +!TREE: | | | | Scalar -> Integer -> Expr -> LiteralConstant -> IntLiteralConstant = '5' |
| 28 | + |
| 29 | +!UNPARSE: !DIR$ PREFETCH a, b(3:5) |
| 30 | + !dir$ prefetch a, b(3:5) |
| 31 | + res = a + b(4) |
| 32 | + |
| 33 | +!TREE: | | ExecutionPartConstruct -> ExecutableConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> Name = 'res' |
| 34 | +!TREE: | | Designator -> DataRef -> ArrayElement |
| 35 | +!TREE: | | | DataRef -> Name = 'b' |
| 36 | +!TREE: | | | SectionSubscript -> Integer -> Expr -> Add |
| 37 | +!TREE: | | | | Expr -> Designator -> DataRef -> Name = 'i' |
| 38 | +!TREE: | | | | Expr -> LiteralConstant -> IntLiteralConstant = '2' |
| 39 | + |
| 40 | +!UNPARSE: !DIR$ PREFETCH res, b(i+2) |
| 41 | + !dir$ prefetch res, b(i+2) |
| 42 | + res = res + b(i+2) |
| 43 | +end subroutine |
| 44 | + |
| 45 | +subroutine test_prefetch_02(n, a) |
| 46 | + integer, intent(in) :: n |
| 47 | + integer, intent(in) :: a(n) |
| 48 | + type :: t |
| 49 | + real, allocatable :: x(:, :) |
| 50 | + end type t |
| 51 | + type(t) :: p |
| 52 | + |
| 53 | + do i = 1, n |
| 54 | +!TREE: | | | | ExecutionPartConstruct -> ExecutableConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> ArrayElement |
| 55 | +!TREE: | | | | | DataRef -> StructureComponent |
| 56 | +!TREE: | | | | | | DataRef -> Name = 'p' |
| 57 | +!TREE: | | | | | | Name = 'x' |
| 58 | +!TREE: | | | | | SectionSubscript -> Integer -> Expr -> Designator -> DataRef -> Name = 'i' |
| 59 | +!TREE: | | | | | SectionSubscript -> SubscriptTriplet |
| 60 | +!TREE: | | | | Designator -> DataRef -> Name = 'a' |
| 61 | + |
| 62 | +!UNPARSE: !DIR$ PREFETCH p%x(i,:), a |
| 63 | + !dir$ prefetch p%x(i, :), a |
| 64 | + do j = 1, n |
| 65 | +!TREE: | | | | | | ExecutionPartConstruct -> ExecutableConstruct -> CompilerDirective -> Prefetch -> Designator -> DataRef -> ArrayElement |
| 66 | +!TREE: | | | | | | | DataRef -> StructureComponent |
| 67 | +!TREE: | | | | | | | | DataRef -> Name = 'p' |
| 68 | +!TREE: | | | | | | | | Name = 'x' |
| 69 | +!TREE: | | | | | | | SectionSubscript -> Integer -> Expr -> Designator -> DataRef -> Name = 'i' |
| 70 | +!TREE: | | | | | | | SectionSubscript -> Integer -> Expr -> Designator -> DataRef -> Name = 'j' |
| 71 | +!TREE: | | | | | | Designator -> DataRef -> ArrayElement |
| 72 | +!TREE: | | | | | | | DataRef -> Name = 'a' |
| 73 | +!TREE: | | | | | | | SectionSubscript -> Integer -> Expr -> Designator -> DataRef -> Name = 'i' |
| 74 | + |
| 75 | +!UNPARSE: !DIR$ PREFETCH p%x(i,j), a(i) |
| 76 | + !dir$ prefetch p%x(i, j), a(i) |
| 77 | + p%x(i, j) = p%x(i, j) ** a(j) |
| 78 | + end do |
| 79 | + end do |
| 80 | +end subroutine |
0 commit comments