; RUN: llc -mtriple=aarch64--linux-gnu -mattr=+sve %s -o - | FileCheck %s ; Test that redundant ptest instruction is removed when using a flag setting brk define i32 @brkpb( %pg, %a, %b) { ; CHECK-LABEL: brkpb: ; CHECK: brkpbs p0.b, p0/z, p1.b, p2.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkpb.z.nxv16i1( %pg, %a, %b) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %pg, %1) %conv = zext i1 %2 to i32 ret i32 %conv } define i32 @brkb( %pg, %a) { ; CHECK-LABEL: brkb: ; CHECK: brkbs p0.b, p0/z, p1.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkb.z.nxv16i1( %pg, %a) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %pg, %1) %conv = zext i1 %2 to i32 ret i32 %conv } define i32 @brkn( %pg, %a, %b) { ; CHECK-LABEL: brkn: ; CHECK: brkns p2.b, p0/z, p1.b, p2.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkn.z.nxv16i1( %pg, %a, %b) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %pg, %1) %conv = zext i1 %2 to i32 ret i32 %conv } ; Test that ptest instruction is not removed when using a non-flag setting brk define i32 @brkpb_neg( %pg, %a, %b) { ; CHECK-LABEL: brkpb_neg: ; CHECK: brkpb p0.b, p0/z, p1.b, p2.b ; CHECK-NEXT: ptest p1, p0.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkpb.z.nxv16i1( %pg, %a, %b) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %a, %1) %conv = zext i1 %2 to i32 ret i32 %conv } define i32 @brkb_neg( %pg, %a) { ; CHECK-LABEL: brkb_neg: ; CHECK: brkb p0.b, p0/z, p1.b ; CHECK-NEXT: ptest p1, p0.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkb.z.nxv16i1( %pg, %a) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %a, %1) %conv = zext i1 %2 to i32 ret i32 %conv } define i32 @brkn_neg( %pg, %a, %b) { ; CHECK-LABEL: brkn_neg: ; CHECK: brkn p2.b, p0/z, p1.b, p2.b ; CHECK-NEXT: ptest p1, p2.b ; CHECK-NEXT: cset w0, ne ; CHECK-NEXT: ret %1 = tail call @llvm.aarch64.sve.brkn.z.nxv16i1( %pg, %a, %b) %2 = tail call i1 @llvm.aarch64.sve.ptest.any.nxv16i1( %a, %1) %conv = zext i1 %2 to i32 ret i32 %conv } declare @llvm.aarch64.sve.brkpb.z.nxv16i1(, , ) declare @llvm.aarch64.sve.brkb.z.nxv16i1(, ) declare @llvm.aarch64.sve.brkn.z.nxv16i1(, , ) declare i1 @llvm.aarch64.sve.ptest.any.nxv16i1(, )