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

[AArch64] Put legal action first for G_ATOMIC_CMPXCHG #74613

Merged
merged 6 commits into from
Dec 15, 2023

Conversation

RoboTux
Copy link
Contributor

@RoboTux RoboTux commented Dec 6, 2023

No description provided.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 6, 2023

@llvm/pr-subscribers-llvm-globalisel

@llvm/pr-subscribers-backend-aarch64

Author: Thomas Preud'homme (RoboTux)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/74613.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp (+3-3)
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 21a412e9360dc..7df49d188c332 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -758,11 +758,11 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
           all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(2, p0)));
 
   getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG)
+      .clampScalar(0, s32, s128)
+      .legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0)))
       .customIf([](const LegalityQuery &Query) {
         return Query.Types[0].getSizeInBits() == 128;
-      })
-      .clampScalar(0, s32, s64)
-      .legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0)));
+      });
 
   getActionDefinitionsBuilder(
       {G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD, G_ATOMICRMW_SUB, G_ATOMICRMW_AND,

@RoboTux RoboTux changed the title Put legal action first for G_ATOMIC_CMPXCHG [AArch64] Put legal action first for G_ATOMIC_CMPXCHG Dec 6, 2023
@@ -758,11 +758,11 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(2, p0)));

getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG)
.clampScalar(0, s32, s128)
.legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0)))
.customIf([](const LegalityQuery &Query) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

That should become a simple custom()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As pointed by Pavel, typeIs(0, s128) is not the same as testing that the size in bits is 128 due to vector. Although the intent is probably to former, keeping the existing check makes this more of an NFC.

.clampScalar(0, s32, s64)
.legalIf(all(typeInSet(0, {s32, s64}), typeIs(1, p0)));
.legalFor({{s32, p0}, {s64, p0}})
.customIf(typeIs(0, s128))
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like rule on 128-bit vector types case was removed, but not sure if it was needed. Is the patch meant to be NFC?

Copy link
Collaborator

Choose a reason for hiding this comment

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

(It might be better to keep it in just to be explicit about the types that are supported.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't follow, the customIf checks for typeIs(0, s128). Is that different from the original check?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Sorry I think I was looking at an older version. I think you could probably use customFor({s128, p0}), but either way this looks OK to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ilinpv pointed out that testing for s128 is not equivalent to what was done so I've changed to keep the old test to keep this more of an RFC. Strangely, it required updating the legalizer-info-validation test. Would you happen to know why that changed?

Copy link
Contributor

@ilinpv ilinpv left a comment

Choose a reason for hiding this comment

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

I think rules might be simplified in the next patch, this one looks good to me.

@RoboTux RoboTux merged commit 4064369 into llvm:main Dec 15, 2023
3 of 4 checks passed
@RoboTux RoboTux deleted the legal_action_first branch April 18, 2024 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants