@@ -214,24 +214,6 @@ static void threadPrivatizeVars(Fortran::lower::AbstractConverter &converter,
214
214
firOpBuilder.restoreInsertionPoint (insPt);
215
215
}
216
216
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
-
235
217
static mlir::Operation *
236
218
createAndSetPrivatizedLoopVar (Fortran::lower::AbstractConverter &converter,
237
219
mlir::Location loc, mlir::Value indexVal,
@@ -570,6 +552,7 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
570
552
mlir::omp::ClauseProcBindKindAttr procBindKindAttr;
571
553
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands,
572
554
reductionVars;
555
+ llvm::SmallVector<mlir::Type> reductionTypes;
573
556
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
574
557
llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
575
558
@@ -581,13 +564,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
581
564
cp.processDefault ();
582
565
cp.processAllocate (allocatorOperands, allocateOperands);
583
566
if (!outerCombined)
584
- cp.processReduction (currentLocation, reductionVars, reductionDeclSymbols,
585
- &reductionSymbols);
586
-
587
- llvm::SmallVector<mlir::Type> reductionTypes;
588
- reductionTypes.reserve (reductionVars.size ());
589
- llvm::transform (reductionVars, std::back_inserter (reductionTypes),
590
- [](mlir::Value v) { return v.getType (); });
567
+ cp.processReduction (currentLocation, reductionVars, reductionTypes,
568
+ reductionDeclSymbols, &reductionSymbols);
591
569
592
570
auto reductionCallback = [&](mlir::Operation *op) {
593
571
llvm::SmallVector<mlir::Location> locs (reductionVars.size (),
@@ -1476,25 +1454,6 @@ genOMP(Fortran::lower::AbstractConverter &converter,
1476
1454
standaloneConstruct.u );
1477
1455
}
1478
1456
1479
- static void convertLoopBounds (Fortran::lower::AbstractConverter &converter,
1480
- mlir::Location loc,
1481
- llvm::SmallVectorImpl<mlir::Value> &lowerBound,
1482
- llvm::SmallVectorImpl<mlir::Value> &upperBound,
1483
- llvm::SmallVectorImpl<mlir::Value> &step,
1484
- std::size_t loopVarTypeSize) {
1485
- fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
1486
- // The types of lower bound, upper bound, and step are converted into the
1487
- // type of the loop variable if necessary.
1488
- mlir::Type loopVarType = getLoopVarType (converter, loopVarTypeSize);
1489
- for (unsigned it = 0 ; it < (unsigned )lowerBound.size (); it++) {
1490
- lowerBound[it] =
1491
- firOpBuilder.createConvert (loc, loopVarType, lowerBound[it]);
1492
- upperBound[it] =
1493
- firOpBuilder.createConvert (loc, loopVarType, upperBound[it]);
1494
- step[it] = firOpBuilder.createConvert (loc, loopVarType, step[it]);
1495
- }
1496
- }
1497
-
1498
1457
static llvm::SmallVector<const Fortran::semantics::Symbol *>
1499
1458
genLoopVars (mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
1500
1459
mlir::Location &loc,
@@ -1590,16 +1549,15 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1590
1549
llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
1591
1550
llvm::SmallVector<mlir::Value> alignedVars, nontemporalVars;
1592
1551
llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1552
+ llvm::SmallVector<mlir::Type> reductionTypes;
1593
1553
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
1594
1554
mlir::omp::ClauseOrderKindAttr orderClauseOperand;
1595
1555
mlir::IntegerAttr simdlenClauseOperand, safelenClauseOperand;
1596
- std::size_t loopVarTypeSize;
1597
1556
1598
1557
ClauseProcessor cp (converter, semaCtx, loopOpClauseList);
1599
- cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv,
1600
- loopVarTypeSize);
1558
+ cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv);
1601
1559
cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1602
- cp.processReduction (loc, reductionVars, reductionDeclSymbols);
1560
+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols);
1603
1561
cp.processIf (Fortran::parser::OmpIfClause::DirectiveNameModifier::Simd,
1604
1562
ifClauseOperand);
1605
1563
cp.processSimdlen (simdlenClauseOperand);
@@ -1610,9 +1568,6 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1610
1568
Fortran::parser::OmpClause::Nontemporal,
1611
1569
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1612
1570
1613
- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1614
- loopVarTypeSize);
1615
-
1616
1571
mlir::TypeRange resultType;
1617
1572
auto simdLoopOp = firOpBuilder.create <mlir::omp::SimdLoopOp>(
1618
1573
loc, resultType, lowerBound, upperBound, step, alignedVars,
@@ -1650,27 +1605,23 @@ static void createWsLoop(Fortran::lower::AbstractConverter &converter,
1650
1605
llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
1651
1606
llvm::SmallVector<mlir::Value> linearVars, linearStepVars;
1652
1607
llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1608
+ llvm::SmallVector<mlir::Type> reductionTypes;
1653
1609
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
1654
1610
llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
1655
1611
mlir::omp::ClauseOrderKindAttr orderClauseOperand;
1656
1612
mlir::omp::ClauseScheduleKindAttr scheduleValClauseOperand;
1657
1613
mlir::UnitAttr nowaitClauseOperand, byrefOperand, scheduleSimdClauseOperand;
1658
1614
mlir::IntegerAttr orderedClauseOperand;
1659
1615
mlir::omp::ScheduleModifierAttr scheduleModClauseOperand;
1660
- std::size_t loopVarTypeSize;
1661
1616
1662
1617
ClauseProcessor cp (converter, semaCtx, beginClauseList);
1663
- cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv,
1664
- loopVarTypeSize);
1618
+ cp.processCollapse (loc, eval, lowerBound, upperBound, step, iv);
1665
1619
cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1666
- cp.processReduction (loc, reductionVars, reductionDeclSymbols,
1620
+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols,
1667
1621
&reductionSymbols);
1668
1622
cp.processTODO <Fortran::parser::OmpClause::Linear,
1669
1623
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1670
1624
1671
- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1672
- loopVarTypeSize);
1673
-
1674
1625
if (ReductionProcessor::doReductionByRef (reductionVars))
1675
1626
byrefOperand = firOpBuilder.getUnitAttr ();
1676
1627
@@ -1711,11 +1662,6 @@ static void createWsLoop(Fortran::lower::AbstractConverter &converter,
1711
1662
auto *nestedEval = getCollapsedLoopEval (
1712
1663
eval, Fortran::lower::getCollapseValue (beginClauseList));
1713
1664
1714
- llvm::SmallVector<mlir::Type> reductionTypes;
1715
- reductionTypes.reserve (reductionVars.size ());
1716
- llvm::transform (reductionVars, std::back_inserter (reductionTypes),
1717
- [](mlir::Value v) { return v.getType (); });
1718
-
1719
1665
auto ivCallback = [&](mlir::Operation *op) {
1720
1666
return genLoopAndReductionVars (op, converter, loc, iv, reductionSymbols,
1721
1667
reductionTypes);
0 commit comments