diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -851,7 +851,7 @@ if (reductionOpName.contains("add")) return 0; else if (reductionOpName.contains("multiply") || - reductionOpName.contains("and")) + reductionOpName.contains("and") || reductionOpName.contains("eqv")); return 1; TODO(loc, "Reduction of some intrinsic operators is not supported"); } @@ -928,6 +928,9 @@ case Fortran::parser::DefinedOperator::IntrinsicOperator::AND: reductionOp = builder.create(loc, op1, op2); break; + case Fortran::parser::DefinedOperator::IntrinsicOperator::EQV: + reductionOp = builder.create(loc, arith::CmpIPredicate::eq, op1, op2); + break; default: TODO(loc, "Reduction of some intrinsic operators is not supported"); } @@ -1014,6 +1017,8 @@ break; case Fortran::parser::DefinedOperator::IntrinsicOperator::AND: return "and_reduction"; + case Fortran::parser::DefinedOperator::IntrinsicOperator::EQV: + return "eqv_reduction"; default: reductionName = "other_reduction"; break; @@ -1123,6 +1128,7 @@ case Fortran::parser::DefinedOperator::IntrinsicOperator::Add: case Fortran::parser::DefinedOperator::IntrinsicOperator::Multiply: case Fortran::parser::DefinedOperator::IntrinsicOperator::AND: + case Fortran::parser::DefinedOperator::IntrinsicOperator::EQV: break; default: @@ -1824,6 +1830,7 @@ case Fortran::parser::DefinedOperator::IntrinsicOperator::Add: case Fortran::parser::DefinedOperator::IntrinsicOperator::Multiply: case Fortran::parser::DefinedOperator::IntrinsicOperator::AND: + case Fortran::parser::DefinedOperator::IntrinsicOperator::EQV: break; default: continue; @@ -1835,9 +1842,7 @@ mlir::Value reductionVal = converter.getSymbolAddress(*symbol); mlir::Type reductionType = reductionVal.getType().cast().getEleTy(); - - if (intrinsicOp != - Fortran::parser::DefinedOperator::IntrinsicOperator::AND) { + if (!reductionType.isa()) { if (!reductionType.isIntOrIndexOrFloat()) continue; } @@ -1845,8 +1850,7 @@ if (auto loadOp = mlir::dyn_cast( reductionValUse.getOwner())) { mlir::Value loadVal = loadOp.getRes(); - if (intrinsicOp == Fortran::parser::DefinedOperator:: - IntrinsicOperator::AND) { + if (reductionType.isa()) { mlir::Operation *reductionOp = findReductionChain(loadVal); fir::ConvertOp convertOp = getConvertFromReductionOp(reductionOp, loadVal);