-
Notifications
You must be signed in to change notification settings - Fork 55
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
Conversation
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
Outdated
Show resolved
Hide resolved
…n.cpp Remove extra newline
There was a problem hiding this 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!
There was a problem hiding this 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))) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
SmallVector<llvm::PHINode *> phis; | ||
llvm::BasicBlock *continuationBlock = | ||
convertOmpOpRegions(region, "omp.data.region", builder, | ||
moduleTranslation, bodyGenStatus, &phis); | ||
builder.SetInsertPoint(continuationBlock, | ||
continuationBlock->getFirstInsertionPt()); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
) 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.
Updated fix for mixing target data op and target op.