[llvm] 665d79f - [AArch64][GlobalISel] Implement G_ICMP support for oversize pointer vectors.
Amara Emerson via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 20 22:21:51 PST 2024
Author: Amara Emerson
Date: 2024-12-20T22:21:44-08:00
New Revision: 665d79f2e967a5eee6fff93685e45f50cf24cab2
URL: https://github.com/llvm/llvm-project/commit/665d79f2e967a5eee6fff93685e45f50cf24cab2
DIFF: https://github.com/llvm/llvm-project/commit/665d79f2e967a5eee6fff93685e45f50cf24cab2.diff
LOG: [AArch64][GlobalISel] Implement G_ICMP support for oversize pointer vectors.
Added:
Modified:
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
Removed:
################################################################################
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
index f83ad7aa7460eb..155d98f0865f7a 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -563,13 +563,16 @@ AArch64LegalizerInfo::AArch64LegalizerInfo(const AArch64Subtarget &ST)
[=](const LegalityQuery &Query) { return Query.Types[1] == v2s16; },
1, s32)
.minScalarOrEltIf(
- [=](const LegalityQuery &Query) { return Query.Types[1] == v2p0; }, 0,
- s64)
+ [=](const LegalityQuery &Query) {
+ return Query.Types[1].isPointerVector();
+ },
+ 0, s64)
.moreElementsToNextPow2(1)
.clampNumElements(1, v8s8, v16s8)
.clampNumElements(1, v4s16, v8s16)
.clampNumElements(1, v2s32, v4s32)
.clampNumElements(1, v2s64, v2s64)
+ .clampNumElements(1, v2p0, v2p0)
.customIf(isVector(0));
getActionDefinitionsBuilder(G_FCMP)
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
index d96f6fbc12c7ca..40fd92b9504e00 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/legalize-cmp.mir
@@ -541,3 +541,68 @@ body: |
%zext:_(s32) = G_ZEXT %2(s8)
$w0 = COPY %zext(s32)
RET_ReallyLR
+...
+---
+name: test_4xs64_ne
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins:
+ ; CHECK-LABEL: name: test_4xs64_ne
+ ; CHECK: [[DEF:%[0-9]+]]:_(<2 x s64>) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<2 x s64>) = G_ICMP intpred(eq), [[DEF]](<2 x s64>), [[DEF]]
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
+ ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[C]](s64), [[C]](s64)
+ ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<2 x s64>) = G_XOR [[ICMP]], [[BUILD_VECTOR]]
+ ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(<2 x s64>) = G_ICMP intpred(eq), [[DEF]](<2 x s64>), [[DEF]]
+ ; CHECK-NEXT: [[BUILD_VECTOR1:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[C]](s64), [[C]](s64)
+ ; CHECK-NEXT: [[XOR1:%[0-9]+]]:_(<2 x s64>) = G_XOR [[ICMP1]], [[BUILD_VECTOR1]]
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(<2 x s32>) = G_TRUNC [[XOR]](<2 x s64>)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(<2 x s32>) = G_TRUNC [[XOR1]](<2 x s64>)
+ ; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[TRUNC]](<2 x s32>), [[TRUNC1]](<2 x s32>)
+ ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[CONCAT_VECTORS]](<4 x s32>), [[C1]](s64)
+ ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
+ ; CHECK-NEXT: %zext:_(s32) = G_AND [[EVEC]], [[C2]]
+ ; CHECK-NEXT: $w0 = COPY %zext(s32)
+ ; CHECK-NEXT: RET_ReallyLR
+ %vec:_(<4 x s64>) = G_IMPLICIT_DEF
+ %cmp:_(<4 x s1>) = G_ICMP intpred(ne), %vec(<4 x s64>), %vec
+ %1:_(s64) = G_CONSTANT i64 1
+ %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp(<4 x s1>), %1
+ %zext:_(s32) = G_ZEXT %elt(s1)
+ $w0 = COPY %zext(s32)
+ RET_ReallyLR
+...
+---
+name: test_4xp0_ne
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins:
+ ; CHECK-LABEL: name: test_4xp0_ne
+ ; CHECK: [[DEF:%[0-9]+]]:_(<2 x p0>) = G_IMPLICIT_DEF
+ ; CHECK-NEXT: [[ICMP:%[0-9]+]]:_(<2 x s64>) = G_ICMP intpred(eq), [[DEF]](<2 x p0>), [[DEF]]
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 -1
+ ; CHECK-NEXT: [[BUILD_VECTOR:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[C]](s64), [[C]](s64)
+ ; CHECK-NEXT: [[XOR:%[0-9]+]]:_(<2 x s64>) = G_XOR [[ICMP]], [[BUILD_VECTOR]]
+ ; CHECK-NEXT: [[ICMP1:%[0-9]+]]:_(<2 x s64>) = G_ICMP intpred(eq), [[DEF]](<2 x p0>), [[DEF]]
+ ; CHECK-NEXT: [[BUILD_VECTOR1:%[0-9]+]]:_(<2 x s64>) = G_BUILD_VECTOR [[C]](s64), [[C]](s64)
+ ; CHECK-NEXT: [[XOR1:%[0-9]+]]:_(<2 x s64>) = G_XOR [[ICMP1]], [[BUILD_VECTOR1]]
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 1
+ ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(<2 x s32>) = G_TRUNC [[XOR]](<2 x s64>)
+ ; CHECK-NEXT: [[TRUNC1:%[0-9]+]]:_(<2 x s32>) = G_TRUNC [[XOR1]](<2 x s64>)
+ ; CHECK-NEXT: [[CONCAT_VECTORS:%[0-9]+]]:_(<4 x s32>) = G_CONCAT_VECTORS [[TRUNC]](<2 x s32>), [[TRUNC1]](<2 x s32>)
+ ; CHECK-NEXT: [[EVEC:%[0-9]+]]:_(s32) = G_EXTRACT_VECTOR_ELT [[CONCAT_VECTORS]](<4 x s32>), [[C1]](s64)
+ ; CHECK-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
+ ; CHECK-NEXT: %zext:_(s32) = G_AND [[EVEC]], [[C2]]
+ ; CHECK-NEXT: $w0 = COPY %zext(s32)
+ ; CHECK-NEXT: RET_ReallyLR
+ %vec:_(<4 x p0>) = G_IMPLICIT_DEF
+ %cmp:_(<4 x s1>) = G_ICMP intpred(ne), %vec(<4 x p0>), %vec
+ %1:_(s64) = G_CONSTANT i64 1
+ %elt:_(s1) = G_EXTRACT_VECTOR_ELT %cmp(<4 x s1>), %1
+ %zext:_(s32) = G_ZEXT %elt(s1)
+ $w0 = COPY %zext(s32)
+ RET_ReallyLR
+...
More information about the llvm-commits
mailing list