1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve %s -o - | FileCheck %s
4 ; Test that redundant ptest instruction is removed when using a flag setting brk
6 define i32 @brkpa(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
9 ; CHECK-NEXT: brkpas p0.b, p0/z, p1.b, p2.b
10 ; CHECK-NEXT: cset w0, ne
12 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkpa.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
13 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
14 %conv = zext i1 %2 to i32
18 define i32 @brkpb(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
21 ; CHECK-NEXT: brkpbs p0.b, p0/z, p1.b, p2.b
22 ; CHECK-NEXT: cset w0, ne
24 %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)
25 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
26 %conv = zext i1 %2 to i32
30 define i32 @brka(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
33 ; CHECK-NEXT: brkas p0.b, p0/z, p1.b
34 ; CHECK-NEXT: cset w0, ne
36 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brka.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a)
37 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
38 %conv = zext i1 %2 to i32
42 define i32 @brkb(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
45 ; CHECK-NEXT: brkbs p0.b, p0/z, p1.b
46 ; CHECK-NEXT: cset w0, ne
48 %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)
49 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
50 %conv = zext i1 %2 to i32
54 define i32 @brkn_all_active(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
55 ; CHECK-LABEL: brkn_all_active:
57 ; CHECK-NEXT: brkns p2.b, p0/z, p1.b, p2.b
58 ; CHECK-NEXT: cset w0, ne
60 %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)
61 %2 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
62 %3 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %2, <vscale x 16 x i1> %1)
63 %conv = zext i1 %3 to i32
67 ; Test that ptest instruction is not removed when using a non-flag setting brk
69 define i32 @brkpa_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
70 ; CHECK-LABEL: brkpa_neg:
72 ; CHECK-NEXT: brkpa p0.b, p0/z, p1.b, p2.b
73 ; CHECK-NEXT: ptest p1, p0.b
74 ; CHECK-NEXT: cset w0, ne
76 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brkpa.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b)
77 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
78 %conv = zext i1 %2 to i32
82 define i32 @brkpb_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
83 ; CHECK-LABEL: brkpb_neg:
85 ; CHECK-NEXT: brkpb p0.b, p0/z, p1.b, p2.b
86 ; CHECK-NEXT: ptest p1, p0.b
87 ; CHECK-NEXT: cset w0, ne
89 %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)
90 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
91 %conv = zext i1 %2 to i32
95 define i32 @brka_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
96 ; CHECK-LABEL: brka_neg:
98 ; CHECK-NEXT: brka p0.b, p0/z, p1.b
99 ; CHECK-NEXT: ptest p1, p0.b
100 ; CHECK-NEXT: cset w0, ne
102 %1 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.brka.z.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a)
103 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
104 %conv = zext i1 %2 to i32
108 define i32 @brkb_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a) {
109 ; CHECK-LABEL: brkb_neg:
111 ; CHECK-NEXT: brkb p0.b, p0/z, p1.b
112 ; CHECK-NEXT: ptest p1, p0.b
113 ; CHECK-NEXT: cset w0, ne
115 %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)
116 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
117 %conv = zext i1 %2 to i32
121 define i32 @brkn_neg(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
122 ; CHECK-LABEL: brkn_neg:
124 ; CHECK-NEXT: brkn p2.b, p0/z, p1.b, p2.b
125 ; CHECK-NEXT: ptest p1, p2.b
126 ; CHECK-NEXT: cset w0, ne
128 %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)
129 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %a, <vscale x 16 x i1> %1)
130 %conv = zext i1 %2 to i32
134 define i32 @brkn_neg2(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %a, <vscale x 16 x i1> %b) {
135 ; CHECK-LABEL: brkn_neg2:
137 ; CHECK-NEXT: brkn p2.b, p0/z, p1.b, p2.b
138 ; CHECK-NEXT: ptest p0, p2.b
139 ; CHECK-NEXT: cset w0, ne
141 %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)
142 %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1> %pg, <vscale x 16 x i1> %1)
143 %conv = zext i1 %2 to i32
147 declare <vscale x 16 x i1> @llvm.aarch64.sve.brkpa.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>, <vscale x 16 x i1>)
148 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>)
149 declare <vscale x 16 x i1> @llvm.aarch64.sve.brka.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
150 declare <vscale x 16 x i1> @llvm.aarch64.sve.brkb.z.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
151 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>)
152 declare i1 @llvm.aarch64.sve.ptest.any.nxv16i1(<vscale x 16 x i1>, <vscale x 16 x i1>)
153 declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32)