@@ -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,
@@ -568,6 +550,7 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
568
550
mlir::omp::ClauseProcBindKindAttr procBindKindAttr;
569
551
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands,
570
552
reductionVars;
553
+ llvm::SmallVector<mlir::Type> reductionTypes;
571
554
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
572
555
llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
573
556
@@ -578,13 +561,8 @@ genParallelOp(Fortran::lower::AbstractConverter &converter,
578
561
cp.processDefault ();
579
562
cp.processAllocate (allocatorOperands, allocateOperands);
580
563
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);
588
566
589
567
auto reductionCallback = [&](mlir::Operation *op) {
590
568
llvm::SmallVector<mlir::Location> locs (reductionVars.size (),
@@ -1465,25 +1443,6 @@ genOMP(Fortran::lower::AbstractConverter &converter,
1465
1443
standaloneConstruct.u );
1466
1444
}
1467
1445
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
-
1487
1446
static llvm::SmallVector<const Fortran::semantics::Symbol *>
1488
1447
genLoopVars (mlir::Operation *op, Fortran::lower::AbstractConverter &converter,
1489
1448
mlir::Location &loc,
@@ -1517,7 +1476,7 @@ genLoopAndReductionVars(
1517
1476
mlir::Location &loc,
1518
1477
llvm::ArrayRef<const Fortran::semantics::Symbol *> loopArgs,
1519
1478
llvm::ArrayRef<const Fortran::semantics::Symbol *> reductionArgs,
1520
- llvm::SmallVectorImpl <mlir::Type> & reductionTypes) {
1479
+ llvm::ArrayRef <mlir::Type> reductionTypes) {
1521
1480
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder ();
1522
1481
1523
1482
llvm::SmallVector<mlir::Type> blockArgTypes;
@@ -1579,16 +1538,15 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1579
1538
llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
1580
1539
llvm::SmallVector<mlir::Value> alignedVars, nontemporalVars;
1581
1540
llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1541
+ llvm::SmallVector<mlir::Type> reductionTypes;
1582
1542
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
1583
1543
mlir::omp::ClauseOrderKindAttr orderClauseOperand;
1584
1544
mlir::IntegerAttr simdlenClauseOperand, safelenClauseOperand;
1585
- std::size_t loopVarTypeSize;
1586
1545
1587
1546
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);
1590
1548
cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1591
- cp.processReduction (loc, reductionVars, reductionDeclSymbols);
1549
+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols);
1592
1550
cp.processIf (clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
1593
1551
cp.processSimdlen (simdlenClauseOperand);
1594
1552
cp.processSafelen (safelenClauseOperand);
@@ -1598,9 +1556,6 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
1598
1556
Fortran::parser::OmpClause::Nontemporal,
1599
1557
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1600
1558
1601
- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1602
- loopVarTypeSize);
1603
-
1604
1559
mlir::TypeRange resultType;
1605
1560
auto simdLoopOp = firOpBuilder.create <mlir::omp::SimdLoopOp>(
1606
1561
loc, resultType, lowerBound, upperBound, step, alignedVars,
@@ -1638,27 +1593,23 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
1638
1593
llvm::SmallVector<mlir::Value> lowerBound, upperBound, step, reductionVars;
1639
1594
llvm::SmallVector<mlir::Value> linearVars, linearStepVars;
1640
1595
llvm::SmallVector<const Fortran::semantics::Symbol *> iv;
1596
+ llvm::SmallVector<mlir::Type> reductionTypes;
1641
1597
llvm::SmallVector<mlir::Attribute> reductionDeclSymbols;
1642
1598
llvm::SmallVector<const Fortran::semantics::Symbol *> reductionSymbols;
1643
1599
mlir::omp::ClauseOrderKindAttr orderClauseOperand;
1644
1600
mlir::omp::ClauseScheduleKindAttr scheduleValClauseOperand;
1645
1601
mlir::UnitAttr nowaitClauseOperand, byrefOperand, scheduleSimdClauseOperand;
1646
1602
mlir::IntegerAttr orderedClauseOperand;
1647
1603
mlir::omp::ScheduleModifierAttr scheduleModClauseOperand;
1648
- std::size_t loopVarTypeSize;
1649
1604
1650
1605
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);
1653
1607
cp.processScheduleChunk (stmtCtx, scheduleChunkClauseOperand);
1654
- cp.processReduction (loc, reductionVars, reductionDeclSymbols,
1608
+ cp.processReduction (loc, reductionVars, reductionTypes, reductionDeclSymbols,
1655
1609
&reductionSymbols);
1656
1610
cp.processTODO <Fortran::parser::OmpClause::Linear,
1657
1611
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1658
1612
1659
- convertLoopBounds (converter, loc, lowerBound, upperBound, step,
1660
- loopVarTypeSize);
1661
-
1662
1613
if (ReductionProcessor::doReductionByRef (reductionVars))
1663
1614
byrefOperand = firOpBuilder.getUnitAttr ();
1664
1615
@@ -1699,11 +1650,6 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
1699
1650
auto *nestedEval = getCollapsedLoopEval (
1700
1651
eval, Fortran::lower::getCollapseValue (beginClauseList));
1701
1652
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
-
1707
1653
auto ivCallback = [&](mlir::Operation *op) {
1708
1654
return genLoopAndReductionVars (op, converter, loc, iv, reductionSymbols,
1709
1655
reductionTypes);
0 commit comments