[llvm] 6009122 - AArch64/GlobalISel: Remove pointless s1 legalize rules
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 12 13:54:17 PDT 2022
Author: Matt Arsenault
Date: 2022-04-12T16:54:04-04:00
New Revision: 600912225024663a2d208cb1a3b69aa77795a7ab
URL: https://github.com/llvm/llvm-project/commit/600912225024663a2d208cb1a3b69aa77795a7ab
DIFF: https://github.com/llvm/llvm-project/commit/600912225024663a2d208cb1a3b69aa77795a7ab.diff
LOG: AArch64/GlobalISel: Remove pointless s1 legalize rules
These have no net effect on the legalize rules.
Added:
Modified:
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index fbdc22a5059d3..74ec9373ce9ef 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -169,7 +169,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
.scalarize(0);
getActionDefinitionsBuilder({G_SREM, G_UREM, G_SDIVREM, G_UDIVREM})
- .lowerFor({s1, s8, s16, s32, s64, v2s64, v4s32, v2s32})
+ .lowerFor({s8, s16, s32, s64, v2s64, v4s32, v2s32})
.widenScalarOrEltToNextPow2(0)
.clampScalarOrElt(0, s32, s64)
.clampNumElements(0, v2s32, v4s32)
@@ -180,7 +180,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
getActionDefinitionsBuilder({G_SMULO, G_UMULO})
.widenScalarToNextPow2(0, /*Min = */ 32)
.clampScalar(0, s32, s64)
- .lowerIf(typeIs(1, s1));
+ .lower();
getActionDefinitionsBuilder({G_SMULH, G_UMULH})
.legalFor({s64, v8s16, v16s8, v4s32})
@@ -532,7 +532,7 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG_WITH_SUCCESS)
.lowerIf(
- all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(1, s1), typeIs(2, p0)));
+ all(typeInSet(0, {s8, s16, s32, s64, s128}), typeIs(2, p0)));
getActionDefinitionsBuilder(G_ATOMIC_CMPXCHG)
.customIf([](const LegalityQuery &Query) {
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir
index 8731fe4c9b38e..660b2b04fbf7a 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-rem.mir
@@ -64,6 +64,57 @@ body: |
$w0 = COPY %5(s32)
...
+---
+name: test_srem_1
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: test_srem_1
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
+ ; CHECK-NEXT: [[SEXT_INREG:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC]], 1
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
+ ; CHECK-NEXT: [[SEXT_INREG1:%[0-9]+]]:_(s32) = G_SEXT_INREG [[TRUNC1]], 1
+ ; CHECK-NEXT: [[SDIV:%[0-9]+]]:_(s32) = G_SDIV [[SEXT_INREG]], [[SEXT_INREG1]]
+ ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[SDIV]], [[SEXT_INREG1]]
+ ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[SEXT_INREG]], [[MUL]]
+ ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
+ %0:_(s64) = COPY $x0
+ %1:_(s64) = COPY $x1
+ %2:_(s1) = G_TRUNC %0(s64)
+ %3:_(s1) = G_TRUNC %1(s64)
+ %4:_(s1) = G_SREM %2, %3
+ %5:_(s32) = G_ANYEXT %4(s1)
+ $w0 = COPY %5(s32)
+
+...
+
+---
+name: test_urem_1
+body: |
+ bb.0.entry:
+ ; CHECK-LABEL: name: test_urem_1
+ ; CHECK: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+ ; CHECK-NEXT: [[COPY1:%[0-9]+]]:_(s64) = COPY $x1
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s32) = G_TRUNC [[COPY]](s64)
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[TRUNC]], [[C]]
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(s32) = G_TRUNC [[COPY1]](s64)
+ ; CHECK-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[TRUNC1]], [[C]]
+ ; CHECK-NEXT: [[UDIV:%[0-9]+]]:_(s32) = G_UDIV [[AND]], [[AND1]]
+ ; CHECK-NEXT: [[MUL:%[0-9]+]]:_(s32) = G_MUL [[UDIV]], [[AND1]]
+ ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s32) = G_SUB [[AND]], [[MUL]]
+ ; CHECK-NEXT: $w0 = COPY [[SUB]](s32)
+ %0:_(s64) = COPY $x0
+ %1:_(s64) = COPY $x1
+ %2:_(s1) = G_TRUNC %0(s64)
+ %3:_(s1) = G_TRUNC %1(s64)
+ %4:_(s1) = G_UREM %2, %3
+ %5:_(s32) = G_ANYEXT %4(s1)
+ $w0 = COPY %5(s32)
+
+...
+
---
name: test_frem
body: |
More information about the llvm-commits
mailing list