[PATCH] D147516: [AArch64][GISel] Legalize non-power-of-two G_CTLZ
Sam Elliott via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 4 03:47:02 PDT 2023
lenary created this revision.
Herald added subscribers: hiraditya, kristof.beyls.
Herald added a project: All.
lenary requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This fixes a crash found in PR61549.
Depends on D147515 <https://reviews.llvm.org/D147515>
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D147516
Files:
llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
llvm/test/CodeGen/AArch64/GlobalISel/legalize-ctlz.mir
Index: llvm/test/CodeGen/AArch64/GlobalISel/legalize-ctlz.mir
===================================================================
--- llvm/test/CodeGen/AArch64/GlobalISel/legalize-ctlz.mir
+++ llvm/test/CodeGen/AArch64/GlobalISel/legalize-ctlz.mir
@@ -218,3 +218,29 @@
RET_ReallyLR implicit $d0
...
+---
+name: test_s35
+alignment: 4
+tracksRegLiveness: true
+body: |
+ bb.1:
+ liveins: $x0
+
+ ; CHECK-LABEL: name: test_s35
+ ; CHECK: liveins: $x0
+ ; CHECK-NEXT: {{ $}}
+ ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY $x0
+ ; CHECK-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738367
+ ; CHECK-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[COPY]], [[C]]
+ ; CHECK-NEXT: [[CTLZ:%[0-9]+]]:_(s64) = G_CTLZ [[AND]](s64)
+ ; CHECK-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 29
+ ; CHECK-NEXT: [[SUB:%[0-9]+]]:_(s64) = G_SUB [[CTLZ]], [[C1]]
+ ; CHECK-NEXT: $x0 = COPY [[SUB]](s64)
+ ; CHECK-NEXT: RET_ReallyLR implicit $x0
+ %1:_(s64) = COPY $x0
+ %0:_(s35) = G_TRUNC %1(s64)
+ %2:_(s35) = G_CTLZ %0(s35)
+ %3:_(s64) = G_ANYEXT %2(s35)
+ $x0 = COPY %3(s64)
+ RET_ReallyLR implicit $x0
+...
Index: llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
===================================================================
--- llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
+++ llvm/lib/Target/AArch64/GISel/AArch64LegalizerInfo.cpp
@@ -681,9 +681,10 @@
getActionDefinitionsBuilder(G_BUILD_VECTOR_TRUNC).lower();
getActionDefinitionsBuilder(G_CTLZ)
- .legalForCartesianProduct(
- {s32, s64, v8s8, v16s8, v4s16, v8s16, v2s32, v4s32})
+ .legalForCartesianProduct({s32, s64, v8s8, v16s8, v4s16, v8s16, v2s32, v4s32})
+ .widenScalarToNextPow2(1, /*Min=*/32)
.scalarize(1);
+
getActionDefinitionsBuilder(G_CTLZ_ZERO_UNDEF).lower();
// TODO: Custom lowering for v2s32, v4s32, v2s64.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147516.510738.patch
Type: text/x-patch
Size: 1917 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230404/ad156e80/attachment.bin>
More information about the llvm-commits
mailing list