Skip to content

Commit a4168a6

Browse files
authored
[flang][OpenMP] Use OmpDirectiveSpecification in DECLARE_REDUCTION (#160192)
1 parent 6ac40aa commit a4168a6

11 files changed

+188
-146
lines changed

flang/include/flang/Parser/parse-tree.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4962,11 +4962,9 @@ struct OpenMPDeclareMapperConstruct {
49624962
// 2.16 declare-reduction -> DECLARE REDUCTION (reduction-identifier : type-list
49634963
// : combiner) [initializer-clause]
49644964
struct OpenMPDeclareReductionConstruct {
4965-
TUPLE_CLASS_BOILERPLATE(OpenMPDeclareReductionConstruct);
4965+
WRAPPER_CLASS_BOILERPLATE(
4966+
OpenMPDeclareReductionConstruct, OmpDirectiveSpecification);
49664967
CharBlock source;
4967-
std::tuple<Verbatim, common::Indirection<OmpReductionSpecifier>,
4968-
std::optional<OmpClauseList>>
4969-
t;
49704968
};
49714969

49724970
// 2.8.2 declare-simd -> DECLARE SIMD [(proc-name)] [declare-simd-clause[ [,]

flang/lib/Parser/openmp-parsers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,9 +1716,9 @@ TYPE_PARSER(sourced(construct<OmpDeclareVariantDirective>(
17161716

17171717
// 2.16 Declare Reduction Construct
17181718
TYPE_PARSER(sourced(construct<OpenMPDeclareReductionConstruct>(
1719-
verbatim("DECLARE REDUCTION"_tok) || verbatim("DECLARE_REDUCTION"_tok),
1720-
"(" >> indirect(Parser<OmpReductionSpecifier>{}) / ")",
1721-
maybe(Parser<OmpClauseList>{}))))
1719+
predicated(Parser<OmpDirectiveName>{},
1720+
IsDirective(llvm::omp::Directive::OMPD_declare_reduction)) >=
1721+
Parser<OmpDirectiveSpecification>{})))
17221722

17231723
// declare-target with list
17241724
TYPE_PARSER(sourced(construct<OmpDeclareTargetWithList>(

flang/lib/Parser/unparse.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,11 +2507,8 @@ class UnparseVisitor {
25072507
}
25082508
void Unparse(const OpenMPDeclareReductionConstruct &x) {
25092509
BeginOpenMP();
2510-
Word("!$OMP DECLARE REDUCTION ");
2511-
Put("(");
2512-
Walk(std::get<common::Indirection<OmpReductionSpecifier>>(x.t));
2513-
Put(")");
2514-
Walk(std::get<std::optional<OmpClauseList>>(x.t));
2510+
Word("!$OMP ");
2511+
Walk(x.v);
25152512
Put("\n");
25162513
EndOpenMP();
25172514
}

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -624,11 +624,6 @@ template <typename Checker> struct DirectiveSpellingVisitor {
624624
checker_(std::get<parser::Verbatim>(x.t).source, Directive::OMPD_assumes);
625625
return false;
626626
}
627-
bool Pre(const parser::OpenMPDeclareReductionConstruct &x) {
628-
checker_(std::get<parser::Verbatim>(x.t).source,
629-
Directive::OMPD_declare_reduction);
630-
return false;
631-
}
632627
bool Pre(const parser::OpenMPDeclareSimdConstruct &x) {
633628
checker_(
634629
std::get<parser::Verbatim>(x.t).source, Directive::OMPD_declare_simd);
@@ -1626,9 +1621,21 @@ void OmpStructureChecker::Leave(const parser::OpenMPDeclareMapperConstruct &) {
16261621

16271622
void OmpStructureChecker::Enter(
16281623
const parser::OpenMPDeclareReductionConstruct &x) {
1629-
const auto &dir{std::get<parser::Verbatim>(x.t)};
1630-
PushContextAndClauseSets(
1631-
dir.source, llvm::omp::Directive::OMPD_declare_reduction);
1624+
const parser::OmpDirectiveName &dirName{x.v.DirName()};
1625+
PushContextAndClauseSets(dirName.source, dirName.v);
1626+
1627+
const parser::OmpArgumentList &args{x.v.Arguments()};
1628+
if (args.v.size() != 1) {
1629+
context_.Say(args.source,
1630+
"DECLARE_REDUCTION directive should have a single argument"_err_en_US);
1631+
return;
1632+
}
1633+
1634+
const parser::OmpArgument &arg{args.v.front()};
1635+
if (!std::holds_alternative<parser::OmpReductionSpecifier>(arg.u)) {
1636+
context_.Say(arg.source,
1637+
"The argument to the DECLARE_REDUCTION directive should be a reduction-specifier"_err_en_US);
1638+
}
16321639
}
16331640

16341641
void OmpStructureChecker::Leave(

flang/lib/Semantics/resolve-names.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1559,12 +1559,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
15591559

15601560
bool Pre(const parser::OpenMPDeclareReductionConstruct &x) {
15611561
AddOmpSourceRange(x.source);
1562-
parser::OmpClauseList empty(std::list<parser::OmpClause>{});
1563-
auto &maybeClauses{std::get<std::optional<parser::OmpClauseList>>(x.t)};
1564-
ProcessReductionSpecifier(
1565-
std::get<Indirection<parser::OmpReductionSpecifier>>(x.t).value(),
1566-
maybeClauses ? *maybeClauses : empty, declaratives_.back());
1567-
return false;
1562+
return true;
15681563
}
15691564
bool Pre(const parser::OmpMapClause &);
15701565

@@ -1697,6 +1692,11 @@ class OmpVisitor : public virtual DeclarationVisitor {
16971692
// should not reach a point where it calls this function.
16981693
llvm_unreachable("This function should not be reached by AST traversal");
16991694
}
1695+
bool Pre(const parser::OmpReductionSpecifier &x) {
1696+
// OmpReductionSpecifier is handled explicitly, and the AST traversal
1697+
// should not reach a point where it calls this function.
1698+
llvm_unreachable("This function should not be reached by AST traversal");
1699+
}
17001700
bool Pre(const parser::OmpDirectiveSpecification &x);
17011701
void Post(const parser::OmpDirectiveSpecification &) {
17021702
messageHandler().set_currStmtSource(std::nullopt);
@@ -1724,8 +1724,7 @@ class OmpVisitor : public virtual DeclarationVisitor {
17241724
void ProcessMapperSpecifier(const parser::OmpMapperSpecifier &spec,
17251725
const parser::OmpClauseList &clauses);
17261726
void ProcessReductionSpecifier(const parser::OmpReductionSpecifier &spec,
1727-
const parser::OmpClauseList &clauses,
1728-
const parser::OpenMPDeclarativeConstruct *wholeConstruct);
1727+
const parser::OmpClauseList &clauses);
17291728

17301729
void ResolveCriticalName(const parser::OmpArgument &arg);
17311730

@@ -1856,8 +1855,7 @@ std::string MangleDefinedOperator(const parser::CharBlock &name) {
18561855

18571856
void OmpVisitor::ProcessReductionSpecifier(
18581857
const parser::OmpReductionSpecifier &spec,
1859-
const parser::OmpClauseList &clauses,
1860-
const parser::OpenMPDeclarativeConstruct *construct) {
1858+
const parser::OmpClauseList &clauses) {
18611859
const parser::Name *name{nullptr};
18621860
parser::CharBlock mangledName;
18631861
UserReductionDetails reductionDetailsTemp;
@@ -1944,7 +1942,7 @@ void OmpVisitor::ProcessReductionSpecifier(
19441942
PopScope();
19451943
}
19461944

1947-
reductionDetails->AddDecl(construct);
1945+
reductionDetails->AddDecl(declaratives_.back());
19481946

19491947
if (!symbol) {
19501948
symbol = &MakeSymbol(mangledName, Attrs{}, std::move(*reductionDetails));
@@ -1997,7 +1995,7 @@ bool OmpVisitor::Pre(const parser::OmpDirectiveSpecification &x) {
19971995
visitClauses = false;
19981996
},
19991997
[&](const parser::OmpReductionSpecifier &spec) {
2000-
ProcessReductionSpecifier(spec, clauses, declaratives_.back());
1998+
ProcessReductionSpecifier(spec, clauses);
20011999
visitClauses = false;
20022000
},
20032001
[&](const parser::OmpLocator &locator) {

flang/test/Parser/OpenMP/declare-reduction-multi.f90

Lines changed: 87 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -26,111 +26,127 @@ program omp_examples
2626
type(tt) :: values(n), sum, prod, big, small
2727

2828
!$omp declare reduction(+:tt:omp_out%r = omp_out%r + omp_in%r) initializer(omp_priv%r = 0)
29-
!CHECK: !$OMP DECLARE REDUCTION (+:tt: omp_out%r=omp_out%r+omp_in%r
29+
!CHECK: !$OMP DECLARE REDUCTION(+:tt: omp_out%r=omp_out%r+omp_in%r
3030
!CHECK-NEXT: ) INITIALIZER(omp_priv%r=0_4)
31-
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct
32-
!PARSE-TREE: Verbatim
33-
!PARSE-TREE: OmpReductionSpecifier
34-
!PARSE-TREE-NEXT: OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
35-
!PARSE-TREE: OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
36-
!PARSE-TREE-NEXT: Name = 'tt'
37-
!PARSE-TREE: OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
38-
!PARSE-TREE: OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4
31+
32+
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification
33+
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
34+
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
35+
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
36+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
37+
!PARSE-TREE: | | | Name = 'tt'
38+
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r+omp_in%r'
39+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
40+
3941
!$omp declare reduction(*:tt:omp_out%r = omp_out%r * omp_in%r) initializer(omp_priv%r = 1)
40-
!CHECK-NEXT: !$OMP DECLARE REDUCTION (*:tt: omp_out%r=omp_out%r*omp_in%r
42+
!CHECK-NEXT: !$OMP DECLARE REDUCTION(*:tt: omp_out%r=omp_out%r*omp_in%r
4143
!CHECK-NEXT: ) INITIALIZER(omp_priv%r=1_4)
42-
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct
43-
!PARSE-TREE: Verbatim
44-
!PARSE-TREE: OmpReductionSpecifier
45-
!PARSE-TREE: OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
46-
!PARSE-TREE: OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
47-
!PARSE-TREE-NEXT: Name = 'tt'
48-
!PARSE-TREE: OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
49-
!PARSE-TREE: OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
44+
45+
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification
46+
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
47+
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
48+
!PARSE-TREE: | | OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
49+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
50+
!PARSE-TREE: | | | Name = 'tt'
51+
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=omp_out%r*omp_in%r'
52+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
53+
5054
!$omp declare reduction(max:tt:omp_out = mymax(omp_out, omp_in)) initializer(omp_priv%r = 0)
51-
!CHECK-NEXT: !$OMP DECLARE REDUCTION (max:tt: omp_out=mymax(omp_out,omp_in)
55+
!CHECK-NEXT: !$OMP DECLARE REDUCTION(max:tt: omp_out=mymax(omp_out,omp_in)
5256
!CHECK-NEXT: ) INITIALIZER(omp_priv%r=0_4)
53-
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct
54-
!PARSE-TREE: Verbatim
55-
!PARSE-TREE: OmpReductionSpecifier
56-
!PARSE-TREE: OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
57-
!PARSE-TREE: OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
58-
!PARSE-TREE: Name = 'tt'
59-
!PARSE-TREE: OmpReductionCombiner -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
60-
!PARSE-TREE: OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
57+
58+
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification
59+
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
60+
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
61+
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
62+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
63+
!PARSE-TREE: | | | Name = 'tt'
64+
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out=mymax(omp_out,omp_in)'
65+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=0._4'
66+
6167
!$omp declare reduction(min:tt:omp_out%r = min(omp_out%r, omp_in%r)) initializer(omp_priv%r = 1)
62-
!CHECK-NEXT: !$OMP DECLARE REDUCTION (min:tt: omp_out%r=min(omp_out%r,omp_in%r)
68+
!CHECK-NEXT: !$OMP DECLARE REDUCTION(min:tt: omp_out%r=min(omp_out%r,omp_in%r)
6369
!CHECK-NEXT: ) INITIALIZER(omp_priv%r=1_4)
64-
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct
65-
!PARSE-TREE: Verbatim
66-
!PARSE-TREE: OmpReductionSpecifier
67-
!PARSE-TREE: OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
68-
!PARSE-TREE: OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
69-
!PARSE-TREE: Name = 'tt'
70-
!PARSE-TREE: OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
71-
!PARSE-TREE: OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
70+
71+
!PARSE-TREE: DeclarationConstruct -> SpecificationConstruct -> OpenMPDeclarativeConstruct -> OpenMPDeclareReductionConstruct -> OmpDirectiveSpecification
72+
!PARSE-TREE: | OmpDirectiveName -> llvm::omp::Directive = declare reduction
73+
!PARSE-TREE: | OmpArgumentList -> OmpArgument -> OmpReductionSpecifier
74+
!PARSE-TREE: | | OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
75+
!PARSE-TREE: | | OmpTypeNameList -> OmpTypeSpecifier -> TypeSpec -> DerivedTypeSpec
76+
!PARSE-TREE: | | | Name = 'tt'
77+
!PARSE-TREE: | | OmpReductionCombiner -> AssignmentStmt = 'omp_out%r=min(omp_out%r,omp_in%r)'
78+
!PARSE-TREE: | OmpClauseList -> OmpClause -> Initializer -> OmpInitializerClause -> AssignmentStmt = 'omp_priv%r=1._4'
79+
7280
call random_number(values%r)
7381

7482
sum%r = 0
7583
!$omp parallel do reduction(+:sum)
76-
!CHECK: !$OMP PARALLEL DO REDUCTION(+: sum)
84+
!CHECK: !$OMP PARALLEL DO REDUCTION(+: sum)
85+
7786
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
78-
!PARSE-TREE: OmpBeginLoopDirective
79-
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = parallel do
80-
!PARSE-TREE: OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
81-
!PARSE-TREE: Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
82-
!PARSE-TREE: OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'sum
83-
!PARSE-TREE: Flags = None
84-
!PARSE-TREE: DoConstruct
87+
!PARSE-TREE: | OmpBeginLoopDirective
88+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
89+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
90+
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Add
91+
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'sum'
92+
!PARSE-TREE: | | Flags = None
93+
!PARSE-TREE: | DoConstruct
94+
8595
do i = 1, n
8696
sum%r = sum%r + values(i)%r
8797
end do
8898

8999
prod%r = 1
90100
!$omp parallel do reduction(*:prod)
91-
!CHECK: !$OMP PARALLEL DO REDUCTION(*: prod)
92-
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
93-
!PARSE-TREE: OmpBeginLoopDirective
94-
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = parallel do
95-
!PARSE-TREE: OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
96-
!PARSE-TREE: Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
97-
!PARSE-TREE: OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'prod'
98-
!PARSE-TREE: Flags = None
99-
!PARSE-TREE: DoConstruct
101+
!CHECK: !$OMP PARALLEL DO REDUCTION(*: prod)
102+
103+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
104+
!PARSE-TREE: | OmpBeginLoopDirective
105+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
106+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
107+
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> DefinedOperator -> IntrinsicOperator = Multiply
108+
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'prod'
109+
!PARSE-TREE: | | Flags = None
110+
!PARSE-TREE: | DoConstruct
111+
100112
do i = 1, n
101113
prod%r = prod%r * (values(i)%r+0.6)
102114
end do
103115

104116
big%r = 0
105117
!$omp parallel do reduction(max:big)
106-
!CHECK: $OMP PARALLEL DO REDUCTION(max: big)
118+
!CHECK: $OMP PARALLEL DO REDUCTION(max: big)
119+
107120
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
108-
!PARSE-TREE: OmpBeginLoopDirective
109-
!PARSE-TREE: OmpDirectiveName -> llvm::omp::Directive = parallel do
110-
!PARSE-TREE: OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
111-
!PARSE-TREE: Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
112-
!PARSE-TREE: OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'big'
113-
!PARSE-TREE: Flags = None
114-
!PARSE-TREE: DoConstruct
121+
!PARSE-TREE: | OmpBeginLoopDirective
122+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
123+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
124+
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'max'
125+
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'big'
126+
!PARSE-TREE: | | Flags = None
127+
!PARSE-TREE: | DoConstruct
128+
115129
do i = 1, n
116130
big = mymax(values(i), big)
117131
end do
118132

119133
small%r = 1
120134
!$omp parallel do reduction(min:small)
121-
!CHECK: !$OMP PARALLEL DO REDUCTION(min: small)
122-
!CHECK-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
123-
!CHECK-TREE: OmpBeginLoopDirective
124-
!CHECK-TREE: OmpDirectiveName -> llvm::omp::Directive = parallel do
125-
!CHECK-TREE: OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
126-
!CHECK-TREE: Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
127-
!CHECK-TREE: OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'small'
128-
!PARSE-TREE: Flags = None
129-
!CHECK-TREE: DoConstruct
135+
!CHECK: !$OMP PARALLEL DO REDUCTION(min: small)
136+
137+
!PARSE-TREE: ExecutionPartConstruct -> ExecutableConstruct -> OpenMPConstruct -> OpenMPLoopConstruct
138+
!PARSE-TREE: | OmpBeginLoopDirective
139+
!PARSE-TREE: | | OmpDirectiveName -> llvm::omp::Directive = parallel do
140+
!PARSE-TREE: | | OmpClauseList -> OmpClause -> Reduction -> OmpReductionClause
141+
!PARSE-TREE: | | | Modifier -> OmpReductionIdentifier -> ProcedureDesignator -> Name = 'min'
142+
!PARSE-TREE: | | | OmpObjectList -> OmpObject -> Designator -> DataRef -> Name = 'small'
143+
!PARSE-TREE: | | Flags = None
144+
!PARSE-TREE: | DoConstruct
145+
130146
do i = 1, n
131147
small%r = min(values(i)%r, small%r)
132148
end do
133-
149+
134150
print *, values%r
135151
print *, "sum=", sum%r
136152
print *, "prod=", prod%r

0 commit comments

Comments
 (0)