@@ -214,24 +214,6 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
214214 firOpBuilder.restoreInsertionPoint (insPt);
215215}
216216
217- static mlir::Type getLoopVarType (Fortran::lower::AbstractConverter &converter,
218- std::size_t loopVarTypeSize) {
219- // OpenMP runtime requires 32-bit or 64-bit loop variables.
220- loopVarTypeSize = loopVarTypeSize * 8 ;
221- if (loopVarTypeSize < 32 ) {
222- loopVarTypeSize = 32 ;
223- } else if (loopVarTypeSize > 64 ) {
224- loopVarTypeSize = 64 ;
225- mlir::emitWarning (converter.getCurrentLocation (),
226- " OpenMP loop iteration variable cannot have more than 64 "
227- " bits size and will be narrowed into 64 bits." );
228- }
229- assert ((loopVarTypeSize == 32 || loopVarTypeSize == 64 ) &&
230- " OpenMP loop iteration variable size must be transformed into 32-bit "
231- " or 64-bit" );
232- return converter.getFirOpBuilder ().getIntegerType (loopVarTypeSize);
233- }
234-
235217static mlir::Operation *
236218createAndSetPrivatizedLoopVar (Fortran::lower::AbstractConverter &converter,
237219 mlir::Location loc, mlir::Value indexVal,
@@ -568,6 +550,7 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
568550 mlir::omp::ClauseProcBindKindAttr procBindKindAttr;
569551 llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands,
570552 reductionVars;
553+ llvm::SmallVector<mlir::Type> reductionTypes;
571554 llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
572555 llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
573556
@@ -578,13 +561,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
578561 cp.processDefault ();
579562 cp.processAllocate (allocatorOperands, allocateOperands);
580563 if (!outerCombined)
581- cp.processReduction (currentLocation, reductionVars, reductionDeclSymbols,
582- &reductionSymbols);
583-
584- llvm::SmallVector<mlir::Type> reductionTypes;
585- reductionTypes.reserve (reductionVars.size ());
586- llvm::transform (reductionVars, std::back_inserter (reductionTypes),
587- [](mlir::Value v) { return v.getType (); });
564+ cp.processReduction (currentLocation, reductionVars, reductionTypes,
565+ reductionDeclSymbols, &reductionSymbols);
588566
589567 auto reductionCallback = [&](mlir::Operation *op) {
590568 llvm::SmallVector<mlir::Location> locs (reductionVars.size (),
@@ -1465,25 +1443,6 @@ genOMP(Fortran::lower::AbstractConverter &converter,
14651443 standaloneConstruct.u );
14661444}
14671445
1468- static void convertLoopBounds (Fortran::lower::AbstractConverter &converter,
1469- mlir::Location loc,
1470- llvm::SmallVectorImpl<mlir::Value> &lowerBound,
1471- llvm::SmallVectorImpl<mlir::Value> &upperBound,
1472- llvm::SmallVectorImpl<mlir::Value> &step,
1473- std::size_t loopVarTypeSize) {
1474- fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
1475- // The types of lower bound, upper bound, and step are converted into the
1476- // type of the loop variable if necessary.
1477- mlir::Type loopVarType = getLoopVarType (converter, loopVarTypeSize);
1478- for (unsigned it = 0 ; it < (unsigned )lowerBound.size (); it++) {
1479- lowerBound[it] =
1480- firOpBuilder.createConvert (loc, loopVarType, lowerBound[it]);
1481- upperBound[it] =
1482- firOpBuilder.createConvert (loc, loopVarType, upperBound[it]);
1483- step[it] = firOpBuilder.createConvert (loc, loopVarType, step[it]);
1484- }
1485- }
1486-
14871446static llvm::SmallVector<const Fortran::semantics::Symbol *>
14881447genLoopVars (mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
14891448 mlir::Location &loc,
@@ -1517,7 +1476,7 @@ genLoopAndReductionVars(
15171476 mlir::Location &loc,
15181477 llvm::ArrayRef<const Fortran::semantics::Symbol *> loopArgs,
15191478 llvm::ArrayRef<const Fortran::semantics::Symbol *> reductionArgs,
1520- llvm::SmallVectorImpl <mlir::Type> & reductionTypes) {
1479+ llvm::ArrayRef <mlir::Type> reductionTypes) {
15211480 fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
15221481
15231482 llvm::SmallVector<mlir::Type> blockArgTypes;
@@ -1579,16 +1538,15 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
15791538 llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
15801539 llvm::SmallVector<mlir::Value> alignedVars, nontemporalVars;
15811540 llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1541+ llvm::SmallVector<mlir::Type> reductionTypes;
15821542 llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
15831543 mlir::omp::ClauseOrderKindAttr orderClauseOperand;
15841544 mlir::IntegerAttr simdlenClauseOperand, safelenClauseOperand;
1585- std::size_t loopVarTypeSize;
15861545
15871546 ClauseProcessor cp (converter, semaCtx, loopOpClauseList);
1588- cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv,
1589- loopVarTypeSize);
1547+ cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv);
15901548 cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1591- cp.processReduction (loc, reductionVars, reductionDeclSymbols);
1549+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols);
15921550 cp.processIf (clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
15931551 cp.processSimdlen (simdlenClauseOperand);
15941552 cp.processSafelen (safelenClauseOperand);
@@ -1598,9 +1556,6 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
15981556 Fortran::parser::OmpClause::Nontemporal,
15991557 Fortran::parser::OmpClause::Order>(loc, ompDirective);
16001558
1601- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1602- loopVarTypeSize);
1603-
16041559 mlir::TypeRange resultType;
16051560 auto simdLoopOp = firOpBuilder.create <mlir::omp::SimdLoopOp>(
16061561 loc, resultType, lowerBound, upperBound, step, alignedVars,
@@ -1638,27 +1593,23 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
16381593 llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
16391594 llvm::SmallVector<mlir::Value> linearVars, linearStepVars;
16401595 llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1596+ llvm::SmallVector<mlir::Type> reductionTypes;
16411597 llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
16421598 llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
16431599 mlir::omp::ClauseOrderKindAttr orderClauseOperand;
16441600 mlir::omp::ClauseScheduleKindAttr scheduleValClauseOperand;
16451601 mlir::UnitAttr nowaitClauseOperand, byrefOperand, scheduleSimdClauseOperand;
16461602 mlir::IntegerAttr orderedClauseOperand;
16471603 mlir::omp::ScheduleModifierAttr scheduleModClauseOperand;
1648- std::size_t loopVarTypeSize;
16491604
16501605 ClauseProcessor cp (converter, semaCtx, beginClauseList);
1651- cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv,
1652- loopVarTypeSize);
1606+ cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv);
16531607 cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1654- cp.processReduction (loc, reductionVars, reductionDeclSymbols,
1608+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols,
16551609 &reductionSymbols);
16561610 cp.processTODO <Fortran::parser::OmpClause::Linear,
16571611 Fortran::parser::OmpClause::Order>(loc, ompDirective);
16581612
1659- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1660- loopVarTypeSize);
1661-
16621613 if (ReductionProcessor::doReductionByRef (reductionVars))
16631614 byrefOperand = firOpBuilder.getUnitAttr ();
16641615
@@ -1699,11 +1650,6 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
16991650 auto *nestedEval = getCollapsedLoopEval (
17001651 eval, Fortran::lower::getCollapseValue (beginClauseList));
17011652
1702- llvm::SmallVector<mlir::Type> reductionTypes;
1703- reductionTypes.reserve (reductionVars.size ());
1704- llvm::transform (reductionVars, std::back_inserter (reductionTypes),
1705- [](mlir::Value v) { return v.getType (); });
1706-
17071653 auto ivCallback = [&](mlir::Operation *op) {
17081654 return genLoopAndReductionVars (op, converter, loc, iv, reductionSymbols,
17091655 reductionTypes);
0 commit comments