[llvm] [AArch64] Put legal action first for G_ATOMIC_CMPXCHG (PR #74613)
Thomas Preud'homme via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 04:11:53 PST 2023
https://github.com/RoboTux updated https://github.com/llvm/llvm-project/pull/74613
>From fd4ec060d5d97a5e1667bff0dc1760a7a84aeccb Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme <thomas.preudhomme at arm.com>
Date: Wed, 6 Dec 2023 15:58:22 +0000
Subject: [PATCH 1/3] Put legal action first for G_ATOMIC_CMPXCHG
---
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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,
>From c8cc83194997f9e23d1e041d94aa7f91977722c1 Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme <thomas.preudhomme at arm.com>
Date: Wed, 6 Dec 2023 16:19:23 +0000
Subject: [PATCH 2/3] Simplify custom path.
---
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index 7df49d188c332..dc9177c528991 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -760,9 +760,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
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;
- });
+ .custom();
getActionDefinitionsBuilder(
{G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD, G_ATOMICRMW_SUB, G_ATOMICRMW_AND,
>From b8e1aba878be76f9976d46234d59ed6e33218f31 Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme <thomas.preudhomme at arm.com>
Date: Thu, 7 Dec 2023 12:06:40 +0000
Subject: [PATCH 3/3] Move clamp at the end of the ruleset
---
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index dc9177c528991..3c1ffdf3af805 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -758,9 +758,9 @@ 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)))
- .custom();
+ .legalFor({{s32, p0}, {s64, p0}})
+ .customIf(typeIs(0, s128))
+ .clampScalar(0, s32, s64);
getActionDefinitionsBuilder(
{G_ATOMICRMW_XCHG, G_ATOMICRMW_ADD, G_ATOMICRMW_SUB, G_ATOMICRMW_AND,
More information about the llvm-commits
mailing list