diff --git a/flang/test/Lower/OpenACC/acc-serial.f90 b/flang/test/Lower/OpenACC/acc-serial.f90 index 3ee1278a8a9d1..9ba44ce6b9197 100644 --- a/flang/test/Lower/OpenACC/acc-serial.f90 +++ b/flang/test/Lower/OpenACC/acc-serial.f90 @@ -87,6 +87,11 @@ subroutine acc_serial ! CHECK: acc.yield ! CHECK-NEXT: } + !$acc serial device_type(nvidia) wait + !$acc end serial + +! CHECK: acc.serial wait([#acc.device_type]) + !$acc serial wait(1) !$acc end serial diff --git a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp index 8f150cb33e6f3..06a1f9ef0c8cb 100644 --- a/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp +++ b/mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp @@ -1411,20 +1411,22 @@ static void printWaitClause(mlir::OpAsmPrinter &p, mlir::Operation *op, if (hasDeviceTypeValues(keywordOnly) && hasDeviceTypeValues(deviceTypes)) p << ", "; - unsigned opIdx = 0; - llvm::interleaveComma(llvm::enumerate(*deviceTypes), p, [&](auto it) { - p << "{"; - auto boolAttr = mlir::dyn_cast((*hasDevNum)[it.index()]); - if (boolAttr && boolAttr.getValue()) - p << "devnum: "; - llvm::interleaveComma( - llvm::seq(0, (*segments)[it.index()]), p, [&](auto it) { - p << operands[opIdx] << " : " << operands[opIdx].getType(); - ++opIdx; - }); - p << "}"; - printSingleDeviceType(p, it.value()); - }); + if (hasDeviceTypeValues(deviceTypes)) { + unsigned opIdx = 0; + llvm::interleaveComma(llvm::enumerate(*deviceTypes), p, [&](auto it) { + p << "{"; + auto boolAttr = mlir::dyn_cast((*hasDevNum)[it.index()]); + if (boolAttr && boolAttr.getValue()) + p << "devnum: "; + llvm::interleaveComma( + llvm::seq(0, (*segments)[it.index()]), p, [&](auto it) { + p << operands[opIdx] << " : " << operands[opIdx].getType(); + ++opIdx; + }); + p << "}"; + printSingleDeviceType(p, it.value()); + }); + } p << ")"; }