[llvm-branch-commits] [clang] [flang] [llvm] [Clang][OpenMP] Add permutation clause (PR #92030)
Alexey Bataev via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 22 06:03:42 PDT 2024
================
@@ -15980,7 +15985,44 @@ StmtResult SemaOpenMP::ActOnOpenMPInterchangeDirective(
"affected loops");
// Decode the permutation clause.
- constexpr uint64_t Permutation[] = {1, 0};
+ SmallVector<uint64_t, 2> Permutation;
+ if (!PermutationClause) {
+ Permutation = {1, 0};
+ } else {
+ ArrayRef<Expr *> PermArgs = PermutationClause->getArgsRefs();
+ llvm::BitVector Flags(PermArgs.size());
+ for (Expr *PermArg : PermArgs) {
+ std::optional<llvm::APSInt> PermCstExpr =
+ PermArg->getIntegerConstantExpr(Context);
+ if (!PermCstExpr)
+ continue;
+ uint64_t PermInt = PermCstExpr->getZExtValue();
+ assert(1 <= PermInt && PermInt <= NumLoops &&
+ "Must be a permutation; diagnostic emitted in "
+ "ActOnOpenMPPermutationClause");
+ if (Flags[PermInt - 1]) {
+ SourceRange ExprRange(PermArg->getBeginLoc(), PermArg->getEndLoc());
+ Diag(PermArg->getExprLoc(),
+ diag::err_omp_interchange_permutation_value_repeated)
+ << PermInt << ExprRange;
+ continue;
+ }
+ Flags[PermInt - 1] = true;
+
+ Permutation.push_back(PermInt - 1);
+ }
+
+ if (Permutation.size() != NumLoops)
+ return StmtError();
+ }
+
+ // Nothing to transform with trivial permutation.
+ if (NumLoops <= 1 || llvm::all_of(llvm::enumerate(Permutation), [](auto p) {
----------------
alexey-bataev wrote:
`auto P`
https://github.com/llvm/llvm-project/pull/92030
More information about the llvm-branch-commits
mailing list