1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s | FileCheck %s
4 target triple = "aarch64-unknown-linux-gnu"
6 ; Ensure that a no-op 'and' get removed with vector splat of 1 or ptrue with proper constant
8 define <vscale x 16 x i1> @fold_away_ptrue_and_ptrue() #0 {
9 ; CHECK-LABEL: fold_away_ptrue_and_ptrue:
11 ; CHECK-NEXT: ptrue p0.s
13 %1 = call <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
14 %2 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %1)
15 %3 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
16 %and = and <vscale x 16 x i1> %3, %2
17 ret <vscale x 16 x i1> %and
20 define <vscale x 16 x i1> @fold_away_ptrue_and_splat_predicate() #0 {
21 ; CHECK-LABEL: fold_away_ptrue_and_splat_predicate:
23 ; CHECK-NEXT: ptrue p0.s
25 %1 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> splat(i1 true))
26 %2 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
27 %and = and <vscale x 16 x i1> %1, %2
28 ret <vscale x 16 x i1> %and
31 ; Ensure that one AND operation remain for inactive lanes zeroing with 2 x i1 type (llvm.aarch64.sve.convert.to.svbool.nxv2i1).
32 define <vscale x 16 x i1> @fold_away_ptrue_and_convert_to() #0 {
33 ; CHECK-LABEL: fold_away_ptrue_and_convert_to:
35 ; CHECK-NEXT: ptrue p0.s
36 ; CHECK-NEXT: ptrue p1.d
37 ; CHECK-NEXT: and p0.b, p1/z, p1.b, p0.b
39 %1 = call <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 31)
40 %2 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %1)
41 %3 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
42 %4 = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %3)
43 %5 = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %4)
44 %and = and <vscale x 16 x i1> %5, %2
45 ret <vscale x 16 x i1> %and
48 define <vscale x 16 x i1> @fold_away_two_similar() #0 {
49 ; CHECK-LABEL: fold_away_two_similar:
51 ; CHECK-NEXT: ptrue p0.b
53 %1 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
54 %2 = call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
55 %and = and <vscale x 16 x i1> %1, %2
56 ret <vscale x 16 x i1> %and
59 declare <vscale x 4 x i1> @llvm.aarch64.sve.ptrue.nxv4i1(i32 immarg)
61 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1>)
63 declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 immarg)
65 declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
67 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1>)
70 attributes #0 = { "target-features"="+sve" }