Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MLIR][OpenMP] Updated fix for intermixed TargetDataOp and TargetOp #56

Merged
merged 2 commits into from
Mar 28, 2024

Conversation

jsjodin
Copy link

@jsjodin jsjodin commented Mar 26, 2024

Updated fix for mixing target data op and target op.

Copy link

@agozillon agozillon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM. Might be worth waiting on one other reviewer though for some alternative perspective, but I'll leave that decision up to you!

Copy link

@skatrak skatrak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Jan, I have just one comment but it's not a blocker. This can be merged if needed before addressing it in another patch or directly upstream (if it actually needs to be addressed at all).

@@ -3543,6 +3551,8 @@ convertTopLevelTargetOp(Operation *op, llvm::IRBuilderBase &builder,
LLVM::ModuleTranslation &moduleTranslation) {
if (isa<omp::TargetOp>(op))
return convertOmpTarget(*op, builder, moduleTranslation);
if (isa<omp::TargetDataOp>(op))
return convertOmpTargetData(op, builder, moduleTranslation);
bool interrupted =
op->walk<WalkOrder::PreOrder>([&](omp::TargetOp targetOp) {
if (failed(convertOmpTarget(*targetOp, builder, moduleTranslation)))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't we need to find nested omp.target_data ops here as well?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I forgot this wasn't a recursive function, so there should be a case for the TargetDataOp as well.

Comment on lines +2518 to +2523
SmallVector<llvm::PHINode *> phis;
llvm::BasicBlock *continuationBlock =
convertOmpOpRegions(region, "omp.data.region", builder,
moduleTranslation, bodyGenStatus, &phis);
builder.SetInsertPoint(continuationBlock,
continuationBlock->getFirstInsertionPt());
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity: Why did the original call break things? I see the only difference is that it does some special handling if there is a single block in the region.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The special case assumes that that no new basic blocks are created, which does happen for omp.target, so it seems to generate code in the wrong place because of this.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently still have this change only in ATD, should we upstream it or has it somehow become unnecessary? I don't actually know how to reproduce the issue it fixes, that's why I ask instead of checking myself @jsjodin @TIFitis

@dpalermo dpalermo merged commit d5bf7d3 into amd-trunk-dev Mar 28, 2024
2 checks passed
@jsjodin jsjodin deleted the jleyonberg/intermixeddatatarget branch May 7, 2024 17:21
searlmc1 pushed a commit that referenced this pull request Aug 24, 2024
)

Currently, process of replacing bitwise operations consisting of
`LSR`/`LSL` with `And` is performed by `DAGCombiner`.

However, in certain cases, the `AND` generated by this process
can be removed.

Consider following case:
```
        lsr x8, x8, #56
        and x8, x8, #0xfc
        ldr w0, [x2, x8]
        ret
```

In this case, we can remove the `AND` by changing the target of `LDR`
to `[X2, X8, LSL #2]` and right-shifting amount change to 56 to 58.

after changed:
```
        lsr x8, x8, #58
        ldr w0, [x2, x8, lsl #2]
        ret
```

This patch checks to see if the `SHIFTING` + `AND` operation on load
target can be optimized and optimizes it if it can.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants