1 ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve %s -o - | FileCheck %s
3 ; Test that redundant ptest instruction is removed when using a flag setting brk
5 define i32 @brkpb(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
7 ; CHECK: brkpbs p0.b, p0/z, p1.b, p2.b
8 ; CHECK-NEXT: cset w0, ne
10 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkpb.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
11 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
12 %conv = zext i1 %2 to i32
16 define i32 @brkb(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
18 ; CHECK: brkbs p0.b, p0/z, p1.b
19 ; CHECK-NEXT: cset w0, ne
21 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkb.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a)
22 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
23 %conv = zext i1 %2 to i32
27 define i32 @brkn(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
29 ; CHECK: brkns p2.b, p0/z, p1.b, p2.b
30 ; CHECK-NEXT: cset w0, ne
32 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkn.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
33 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
34 %conv = zext i1 %2 to i32
38 ; Test that ptest instruction is not removed when using a non-flag setting brk
40 define i32 @brkpb_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
41 ; CHECK-LABEL: brkpb_neg:
42 ; CHECK: brkpb p0.b, p0/z, p1.b, p2.b
43 ; CHECK-NEXT: ptest p1, p0.b
44 ; CHECK-NEXT: cset w0, ne
46 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkpb.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
47 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
48 %conv = zext i1 %2 to i32
52 define i32 @brkb_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
53 ; CHECK-LABEL: brkb_neg:
54 ; CHECK: brkb p0.b, p0/z, p1.b
55 ; CHECK-NEXT: ptest p1, p0.b
56 ; CHECK-NEXT: cset w0, ne
58 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkb.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a)
59 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
60 %conv = zext i1 %2 to i32
64 define i32 @brkn_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
65 ; CHECK-LABEL: brkn_neg:
66 ; CHECK: brkn p2.b, p0/z, p1.b, p2.b
67 ; CHECK-NEXT: ptest p1, p2.b
68 ; CHECK-NEXT: cset w0, ne
70 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkn.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
71 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
72 %conv = zext i1 %2 to i32
76 declare <vscale x 16 x i1> @llvm.aarch64.sve.brkpb.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>, <vscale x 16 x i1>)
77 declare <vscale x 16 x i1> @llvm.aarch64.sve.brkb.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
78 declare <vscale x 16 x i1> @llvm.aarch64.sve.brkn.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>, <vscale x 16 x i1>)
79 declare i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)