This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fallback to base's implementation of shouldExpandAtomicCmpXchgInIR and shouldExpandAtomicCmpXchgInIR
ClosedPublic

Authored by lkail on Jul 18 2021, 5:28 AM.

Details

Summary

If we can't decide shouldExpandAtomicCmpXchgInIR or shouldExpandAtomicCmpXchgInIR in PPC's implementation after https://reviews.llvm.org/rGb9c3941cd61de1e1b9e4f3311ddfa92394475f4b, resort to base's implementation.

This fixes internal build of OpenMP which uses atomic operations on float.

Diff Detail

Event Timeline

lkail created this revision.Jul 18 2021, 5:28 AM
lkail requested review of this revision.Jul 18 2021, 5:28 AM
Herald added a project: Restricted Project. · View Herald Transcript
lkail edited the summary of this revision. (Show Details)Jul 18 2021, 5:33 AM
lkail updated this revision to Diff 359618.Jul 18 2021, 5:43 AM
lkail edited the summary of this revision. (Show Details)
lkail updated this revision to Diff 359668.Jul 18 2021, 10:34 PM

Add test for opt.

jsji accepted this revision as: jsji.Jul 19 2021, 9:00 AM
jsji added inline comments.
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
17501

With this change, we pretty much fall back on base implementation for *ALL* other types , except for 128 bits. That means quite some change to existing expansion? If so, I think we should at least add tests for all other types and bits to double confirm.

This revision is now accepted and ready to land.Jul 19 2021, 9:00 AM
This revision was landed with ongoing or failed builds.Jul 19 2021, 11:14 PM
This revision was automatically updated to reflect the committed changes.
lkail added inline comments.Jul 19 2021, 11:19 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
17501

Before https://reviews.llvm.org/rGb9c3941cd61de1e1b9e4f3311ddfa92394475f4b which override shouldExpandAtomicRMWInIR, calling shouldExpandAtomicRMWInIR will falls into TargetLoweringBase's

/// Returns how the IR-level AtomicExpand pass should expand the given
/// AtomicRMW, if at all. Default is to never expand.
virtual AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *RMW) const {
  return RMW->isFloatingPointOperation() ?
    AtomicExpansionKind::CmpXChg : AtomicExpansionKind::None;
}

After override and this patch, I think all other types remain what they are before https://reviews.llvm.org/rGb9c3941cd61de1e1b9e4f3311ddfa92394475f4b.

lkail added inline comments.Jul 19 2021, 11:23 PM
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
17501

And indeed, we're lacking tests while performing AtomicExpand, like atomic float operations. I'll add some tests involving AtomicExpand as regression tests.

dyung added a subscriber: dyung.Jul 20 2021, 1:58 AM

Hi, the test you added is causing a failure on the PS4 build bot, https://lab.llvm.org/buildbot/#/builders/139/builds/7433.

Can you take a look and please fix the test or revert the change so that we can get the bot green again?

One of these tests is failing on Arm bots: https://lab.llvm.org/buildbot/#/builders/171/builds/1162

Because we only build one specific target and this test dir doesn't require PowerPC. I'll fix that.

lkail added a comment.Jul 20 2021, 2:03 AM

Hi, the test you added is causing a failure on the PS4 build bot, https://lab.llvm.org/buildbot/#/builders/139/builds/7433.

Can you take a look and please fix the test or revert the change so that we can get the bot green again?

I'm looking into it. Thanks for notification.

Now I posted the comment I see someone else reported it. I'll leave it up to you then to prevent any confusion.

dyung added a comment.Jul 20 2021, 2:07 AM

Now I posted the comment I see someone else reported it. I'll leave it up to you then to prevent any confusion.

Our PS4 bot also only builds one target (x86_64), so it might be that the test requires a PPC target, and if so, should add that.

lkail added a comment.Jul 20 2021, 2:15 AM

One of these tests is failing on Arm bots: https://lab.llvm.org/buildbot/#/builders/171/builds/1162

Because we only build one specific target and this test dir doesn't require PowerPC. I'll fix that.

https://github.com/llvm/llvm-project/commit/1453f048cf9275ac329b5beb243c3c0986144143 Done.

dyung added a comment.Jul 20 2021, 2:30 AM

Thanks for the fix, our bot is not green, but at least now it isn't your fault!