Meinersbur wrote:
> In the min-bound default, it is obvious to see predicate not getting emitted
> resulting in incorrect semantics. So, either way, we rely on the marker to be
> handled properly.
So we have two versions of the same loop:
```cpp
for (int i_intratile = i_floor; i_intratile < min(n, i_floor + i_tilesize);
++i_intratile)
Body(i_intratile);
```
and
```cpp
for (int i_intratile = i_floor; i_intratile < i_floor + i_tilesize;
++i_intratile)
if (i_intratile < n)
Body(i_intratile);
```
I think we agree that either version is correct. The attribute is supposed to
convey that one version can be transformed into the other, NOT that something
has to be added in order to make it semantically correct. Most
`__attribute__`/`[[attribute]]` are not used for correctness.
For reasons stated before, I would take the first form as starting point, then
attribute it:
```cpp
AttributedStmt: __attribute__(("The following loop can be reinterpreted as a
canonical loop lb=i_floor, ub=i_floor+i_tilesize with predicate if (i_intratile
< n) inserted before the body"))
ForStmt: for (int i_intratile = i_floor; i_intratile < min(n, i_floor +
i_tilesize); ++i_intratile)
CompoundStmt: Body(i_intratile);
```
If encountering in CGStmt: Ignore the AttributedStmt, generate code from ForStmt
If encountering in checkOpenMPLoop: Use the stated lb/ub[^2] instead of trying
to extract it from ForStmt[^1]. Remember the we will have to insert a predicate
in the innermost loop's body (like PreInit is what we have to remember to
insert outside the outermost loop).
[^1]: OpenMP will use the result from `LoopHelper`/`checkOpenMPLoop` anyway and
not even look at the ForStmt after `checkOpenMPLoop`.
[^2]: I am not sure whether it makes sense to store lb/ub/predicate directly in
the AttributedStmt. It could also be a hint "I guarantee that the Stmt I am
attributing as the form `ForStmt(i = lb; i < min(global_max, ub); ++i)`. Use
lb/ub/i < global_max for building LoopHelper"
https://github.com/llvm/llvm-project/pull/191114
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits