[flang-commits] [flang] [flang] Implement !DIR$ VECTOR ALWAYS (PR #93830)
David Truby via flang-commits
flang-commits at lists.llvm.org
Thu Jun 6 06:48:11 PDT 2024
================
@@ -2508,8 +2531,30 @@ class FirConverter : public Fortran::lower::AbstractConverter {
}
}
- void genFIR(const Fortran::parser::CompilerDirective &) {
- // TODO
+ void attachLoopDirective(const Fortran::parser::CompilerDirective &dir,
+ Fortran::lower::pft::Evaluation *e) {
+ while (e->isDirective()) {
+ e = e->lexicalSuccessor;
+ }
+
+ if (e->isA<Fortran::parser::NonLabelDoStmt>()) {
+ e->dirs.push_back(&dir);
+ } else {
+ fir::emitFatalError(toLocation(),
+ "loop directive must appear before a loop");
----------------
DavidTruby wrote:
I'm concerned about allowing this in the presence of OpenACC/OpenMP loops as I think that opens a whole can of worms for implementation. For what it's worth, clang doesn't allow the equivalent clang pragma in the presence of OpenMP directives:
```
❯ cat test.cpp
void foo(int* x, int n) {
#pragma clang loop vectorize(enable)
#pragma omp parallel for
for (int i = 0; i < n; ++i)
x[i] = i+i;
}
❯ clang++ -fopenmp test.cpp
test.cpp:3:1: error: expected a for, while, or do-while loop to follow '#pragma clang loop'
3 | #pragma omp parallel for
| ^
1 error generated.
```
https://github.com/llvm/llvm-project/pull/93830
More information about the flang-commits
mailing list