[llvm] [AArch64] Match vector neg(and X, 1) as CMTST (PR #194833)
Jiang Ning via llvm-commits
llvm-commits at lists.llvm.org
Tue May 5 19:57:40 PDT 2026
================
@@ -0,0 +1,96 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
+; RUN: llc -mtriple=aarch64-none-linux-gnu -mattr=+neon -verify-machineinstrs < %s | FileCheck %s
+
+define <16 x i8> @neg_and_one_v16i8(<16 x i8> %x) {
+; CHECK-LABEL: neg_and_one_v16i8:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v1.16b, #1
+; CHECK-NEXT: cmtst v0.16b, v0.16b, v1.16b
+; CHECK-NEXT: ret
+ %and = and <16 x i8> %x, splat (i8 1)
+ %neg = sub <16 x i8> zeroinitializer, %and
+ ret <16 x i8> %neg
+}
+
+define <8 x i16> @neg_and_one_v8i16(<8 x i16> %x) {
+; CHECK-LABEL: neg_and_one_v8i16:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v1.8h, #1
+; CHECK-NEXT: cmtst v0.8h, v0.8h, v1.8h
+; CHECK-NEXT: ret
+ %and = and <8 x i16> %x, splat (i16 1)
+ %neg = sub <8 x i16> zeroinitializer, %and
+ ret <8 x i16> %neg
+}
+
+define <4 x i32> @neg_and_one_v4i32(<4 x i32> %x) {
+; CHECK-LABEL: neg_and_one_v4i32:
+; CHECK: // %bb.0:
+; CHECK-NEXT: movi v1.4s, #1
+; CHECK-NEXT: cmtst v0.4s, v0.4s, v1.4s
+; CHECK-NEXT: ret
+ %and = and <4 x i32> %x, splat (i32 1)
+ %neg = sub <4 x i32> zeroinitializer, %and
+ ret <4 x i32> %neg
+}
+
+define <2 x i64> @neg_and_one_v2i64(<2 x i64> %x) {
----------------
JiangNingHX wrote:
Done, thanks! I added the v2i128 coverage and refreshed the generated checks. CI is green now.
https://github.com/llvm/llvm-project/pull/194833
More information about the llvm-commits
mailing list