158 lines · plain
1! RUN: %flang_fc1 -fdebug-unparse -fopenmp %s | FileCheck --ignore-case %s2! RUN: %flang_fc1 -fdebug-dump-parse-tree -fopenmp %s | FileCheck --check-prefix="PARSE-TREE" %s3 4!CHECK-LABEL: SUBROUTINE reduce_1 (n, tts)5subroutine reduce_1 ( n, tts )6 type :: tt7 integer :: x8 integer :: y9 end type tt10 type :: tt211 real(8) :: x12 real(8) :: y13 end type14 15 integer :: n16 type(tt) :: tts(n)17 type(tt2) :: tts2(n)18 19!CHECK: !$OMP DECLARE REDUCTION(+:tt: omp_out = tt(omp_out%x - omp_in%x , omp_out%y - &20!CHECK: !$OMP&omp_in%y)) INITIALIZER(omp_priv = tt(0,0))21 22!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification23!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction24!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier25!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add26!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec27!PARSE-TREE: | | | Name = 'tt'28!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance29!PARSE-TREE: | | | OmpStylizedDeclaration30!PARSE-TREE: | | | OmpStylizedDeclaration31!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out=tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'32!PARSE-TREE: | | | | Variable = 'omp_out'33!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'omp_out'34!PARSE-TREE: | | | | Expr = 'tt(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'35!PARSE-TREE: | | | | | StructureConstructor36!PARSE-TREE: | | | | | | DerivedTypeSpec37!PARSE-TREE: | | | | | | | Name = 'tt'38!PARSE-TREE: | | | | | | ComponentSpec39!PARSE-TREE: | | | | | | | ComponentDataSource -> Expr = 'omp_out%x-omp_in%x'40!PARSE-TREE: | | | | | | | | Subtract41!PARSE-TREE: | | | | | | | | | Expr = 'omp_out%x'42!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent43!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_out'44!PARSE-TREE: | | | | | | | | | | | Name = 'x'45!PARSE-TREE: | | | | | | | | | Expr = 'omp_in%x'46!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent47!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_in'48!PARSE-TREE: | | | | | | | | | | | Name = 'x'49!PARSE-TREE: | | | | | | ComponentSpec50!PARSE-TREE: | | | | | | | ComponentDataSource -> Expr = 'omp_out%y-omp_in%y'51!PARSE-TREE: | | | | | | | | Subtract52!PARSE-TREE: | | | | | | | | | Expr = 'omp_out%y'53!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent54!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_out'55!PARSE-TREE: | | | | | | | | | | | Name = 'y'56!PARSE-TREE: | | | | | | | | | Expr = 'omp_in%y'57!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent58!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_in'59!PARSE-TREE: | | | | | | | | | | | Name = 'y'60!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance61!PARSE-TREE: | | OmpStylizedDeclaration62!PARSE-TREE: | | OmpStylizedDeclaration63!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv=tt(x=0_4,y=0_4)'64!PARSE-TREE: | | | Variable = 'omp_priv'65!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'omp_priv'66!PARSE-TREE: | | | Expr = 'tt(x=0_4,y=0_4)'67!PARSE-TREE: | | | | StructureConstructor68!PARSE-TREE: | | | | | DerivedTypeSpec69!PARSE-TREE: | | | | | | Name = 'tt'70!PARSE-TREE: | | | | | ComponentSpec71!PARSE-TREE: | | | | | | ComponentDataSource -> Expr = '0_4'72!PARSE-TREE: | | | | | | | LiteralConstant -> IntLiteralConstant = '0'73!PARSE-TREE: | | | | | ComponentSpec74!PARSE-TREE: | | | | | | ComponentDataSource -> Expr = '0_4'75!PARSE-TREE: | | | | | | | LiteralConstant -> IntLiteralConstant = '0'76!PARSE-TREE: | Flags = {}77 !$omp declare reduction(+ : tt : omp_out = tt(omp_out%x - omp_in%x , omp_out%y - omp_in%y)) initializer(omp_priv = tt(0,0))78 79 80!CHECK: !$OMP DECLARE REDUCTION(+:tt2: omp_out = tt2(omp_out%x - omp_in%x , omp_out%y &81!CHECK: !$OMP&- omp_in%y)) INITIALIZER(omp_priv = tt2(0,0))82 83!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification84!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction85!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier86!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add87!PARSE-TREE: | | OmpTypeNameList -> OmpTypeName -> TypeSpec -> DerivedTypeSpec88!PARSE-TREE: | | | Name = 'tt2'89!PARSE-TREE: | | OmpCombinerExpression -> OmpStylizedInstance90!PARSE-TREE: | | | OmpStylizedDeclaration91!PARSE-TREE: | | | OmpStylizedDeclaration92!PARSE-TREE: | | | Instance -> AssignmentStmt = 'omp_out=tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'93!PARSE-TREE: | | | | Variable = 'omp_out'94!PARSE-TREE: | | | | | Designator -> DataRef -> Name = 'omp_out'95!PARSE-TREE: | | | | Expr = 'tt2(x=omp_out%x-omp_in%x,y=omp_out%y-omp_in%y)'96!PARSE-TREE: | | | | | StructureConstructor97!PARSE-TREE: | | | | | | DerivedTypeSpec98!PARSE-TREE: | | | | | | | Name = 'tt2'99!PARSE-TREE: | | | | | | ComponentSpec100!PARSE-TREE: | | | | | | | ComponentDataSource -> Expr = 'omp_out%x-omp_in%x'101!PARSE-TREE: | | | | | | | | Subtract102!PARSE-TREE: | | | | | | | | | Expr = 'omp_out%x'103!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent104!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_out'105!PARSE-TREE: | | | | | | | | | | | Name = 'x'106!PARSE-TREE: | | | | | | | | | Expr = 'omp_in%x'107!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent108!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_in'109!PARSE-TREE: | | | | | | | | | | | Name = 'x'110!PARSE-TREE: | | | | | | ComponentSpec111!PARSE-TREE: | | | | | | | ComponentDataSource -> Expr = 'omp_out%y-omp_in%y'112!PARSE-TREE: | | | | | | | | Subtract113!PARSE-TREE: | | | | | | | | | Expr = 'omp_out%y'114!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent115!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_out'116!PARSE-TREE: | | | | | | | | | | | Name = 'y'117!PARSE-TREE: | | | | | | | | | Expr = 'omp_in%y'118!PARSE-TREE: | | | | | | | | | | Designator -> DataRef -> StructureComponent119!PARSE-TREE: | | | | | | | | | | | DataRef -> Name = 'omp_in'120!PARSE-TREE: | | | | | | | | | | | Name = 'y'121!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> OmpInitializerExpression -> OmpStylizedInstance122!PARSE-TREE: | | OmpStylizedDeclaration123!PARSE-TREE: | | OmpStylizedDeclaration124!PARSE-TREE: | | Instance -> AssignmentStmt = 'omp_priv=tt2(x=0._8,y=0._8)'125!PARSE-TREE: | | | Variable = 'omp_priv'126!PARSE-TREE: | | | | Designator -> DataRef -> Name = 'omp_priv'127!PARSE-TREE: | | | Expr = 'tt2(x=0._8,y=0._8)'128!PARSE-TREE: | | | | StructureConstructor129!PARSE-TREE: | | | | | DerivedTypeSpec130!PARSE-TREE: | | | | | | Name = 'tt2'131!PARSE-TREE: | | | | | ComponentSpec132!PARSE-TREE: | | | | | | ComponentDataSource -> Expr = '0_4'133!PARSE-TREE: | | | | | | | LiteralConstant -> IntLiteralConstant = '0'134!PARSE-TREE: | | | | | ComponentSpec135!PARSE-TREE: | | | | | | ComponentDataSource -> Expr = '0_4'136!PARSE-TREE: | | | | | | | LiteralConstant -> IntLiteralConstant = '0'137!PARSE-TREE: | Flags = {}138 !$omp declare reduction(+ :tt2 : omp_out = tt2(omp_out%x - omp_in%x , omp_out%y - omp_in%y)) initializer(omp_priv = tt2(0,0))139 140 type(tt) :: diffp = tt( 0, 0 )141 type(tt2) :: diffp2 = tt2( 0, 0 )142 integer :: i143 144 !$omp parallel do reduction(+ : diffp)145 do i = 1, n146 diffp%x = diffp%x + tts(i)%x147 diffp%y = diffp%y + tts(i)%y148 end do149 150 !$omp parallel do reduction(+ : diffp2)151 do i = 1, n152 diffp2%x = diffp2%x + tts2(i)%x153 diffp2%y = diffp2%y + tts2(i)%y154 end do155 156end subroutine reduce_1157!CHECK: END SUBROUTINE reduce_1158