[PATCH] D140649: [AArch64][SelectionDAG] Eliminates redundant zero-extension for 32-bit popcount
Allen zhong via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 6 17:35:38 PST 2023
Allen updated this revision to Diff 487020.
Allen added a comment.
update COPY_TO_REGCLASS with FMOVWSr to avoid the elimination in pass SIMPLE REGISTER COALESCING
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140649/new/
https://reviews.llvm.org/D140649
Files:
llvm/lib/Target/AArch64/AArch64InstrInfo.td
llvm/test/CodeGen/AArch64/arm64-popcnt.ll
Index: llvm/test/CodeGen/AArch64/arm64-popcnt.ll
===================================================================
--- llvm/test/CodeGen/AArch64/arm64-popcnt.ll
+++ llvm/test/CodeGen/AArch64/arm64-popcnt.ll
@@ -6,8 +6,7 @@
define i32 @cnt32_advsimd(i32 %x) nounwind readnone {
; CHECK-LABEL: cnt32_advsimd:
; CHECK: // %bb.0:
-; CHECK-NEXT: mov w8, w0
-; CHECK-NEXT: fmov d0, x8
+; CHECK-NEXT: fmov s0, w0
; CHECK-NEXT: cnt.8b v0, v0
; CHECK-NEXT: uaddlv.8b h0, v0
; CHECK-NEXT: fmov w0, s0
@@ -42,7 +41,7 @@
; CHECK: // %bb.0:
; CHECK-NEXT: // kill: def $d0 killed $d0 def $q0
; CHECK-NEXT: fmov w8, s0
-; CHECK-NEXT: fmov d0, x8
+; CHECK-NEXT: fmov s0, w8
; CHECK-NEXT: cnt.8b v0, v0
; CHECK-NEXT: uaddlv.8b h0, v0
; CHECK-NEXT: fmov w0, s0
@@ -267,6 +266,13 @@
; CHECK-NONEON-NEXT: ccmp w0, #0, #4, eq
; CHECK-NONEON-NEXT: cset w0, eq
; CHECK-NONEON-NEXT: ret
+;
+; CHECK-CSSC-LABEL: ctpop32_ne_one:
+; CHECK-CSSC: // %bb.0:
+; CHECK-CSSC-NEXT: cnt w8, w0
+; CHECK-CSSC-NEXT: cmp w8, #1
+; CHECK-CSSC-NEXT: cset w0, ne
+; CHECK-CSSC-NEXT: ret
%count = tail call i32 @llvm.ctpop.i32(i32 %x)
%cmp = icmp ne i32 %count, 1
ret i1 %cmp
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===================================================================
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -5843,6 +5843,10 @@
(SUBREG_TO_REG (i32 0),
(f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
+// The top bits will be zero from the FMOVWSr
+def : Pat<(v8i8 (bitconvert (i64 (zext GPR32:$Rn)))),
+ (SUBREG_TO_REG (i32 0), (f32 (FMOVWSr GPR32:$Rn)), ssub)>;
+
def : Pat<(v8i16 (scalar_to_vector GPR32:$Rn)),
(SUBREG_TO_REG (i32 0),
(f32 (COPY_TO_REGCLASS GPR32:$Rn, FPR32)), ssub)>;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140649.487020.patch
Type: text/x-patch
Size: 1925 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230107/1fb6c3d6/attachment.bin>
More information about the llvm-commits
mailing list