diff --git a/llvm/lib/Target/AArch64/SVEInstrFormats.td b/llvm/lib/Target/AArch64/SVEInstrFormats.td --- a/llvm/lib/Target/AArch64/SVEInstrFormats.td +++ b/llvm/lib/Target/AArch64/SVEInstrFormats.td @@ -7513,6 +7513,7 @@ let Inst{3-0} = Pd; let Defs = [NZCV]; + let isPTestLike = 1; } multiclass sve2_char_match { diff --git a/llvm/test/CodeGen/AArch64/sve-ptest-removal-match.ll b/llvm/test/CodeGen/AArch64/sve-ptest-removal-match.ll new file mode 100644 --- /dev/null +++ b/llvm/test/CodeGen/AArch64/sve-ptest-removal-match.ll @@ -0,0 +1,38 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve2 %s -o - | FileCheck %s + +; +; MATCH +; + +define i32 @match_nxv16i8( %pg, %a, %b) { +; CHECK-LABEL: match_nxv16i8: +; CHECK: // %bb.0: +; CHECK-NEXT: match p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: cset w0, ne +; CHECK-NEXT: ret + %1 = tail call @llvm.aarch64.sve.match.nxv16i8( %pg, %a, %b) + %2 = tail call i1 @llvm.aarch64.sve.ptest.any( %pg, %1) + %conv = zext i1 %2 to i32 + ret i32 %conv +} + +; +; NMATCH +; + +define i32 @nmatch_nxv16i8( %pg, %a, %b) { +; CHECK-LABEL: nmatch_nxv16i8: +; CHECK: // %bb.0: +; CHECK-NEXT: nmatch p0.b, p0/z, z0.b, z1.b +; CHECK-NEXT: cset w0, ne +; CHECK-NEXT: ret + %1 = tail call @llvm.aarch64.sve.nmatch.nxv16i8( %pg, %a, %b) + %2 = tail call i1 @llvm.aarch64.sve.ptest.any( %pg, %1) + %conv = zext i1 %2 to i32 + ret i32 %conv +} + +declare @llvm.aarch64.sve.match.nxv16i8(, , ) +declare @llvm.aarch64.sve.nmatch.nxv16i8(, , ) +declare i1 @llvm.aarch64.sve.ptest.any(, )