1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2 # RUN: llc -mtriple aarch64-apple-ios -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=DARWIN
3 # RUN: llc -mtriple aarch64 -run-pass=aarch64-prelegalizer-combiner -verify-machineinstrs %s -o - | FileCheck %s --check-prefix=UNKNOWN
5 # Check that on Darwin we can combine to G_BZERO. Without Darwin, this should
9 define void @bzero_unknown_width() { unreachable }
10 define void @bzero_tail_unknown_width() { unreachable }
11 define void @bzero_constant_width() { unreachable }
12 define void @bzero_constant_width_minsize() minsize { unreachable }
13 define void @not_zero() minsize { unreachable }
16 name: bzero_unknown_width
17 tracksRegLiveness: true
21 ; Always use G_BZERO when the memset width is unknown on Darwin.
23 ; DARWIN-LABEL: name: bzero_unknown_width
24 ; DARWIN: liveins: $x0, $x1
25 ; DARWIN: %ptr:_(p0) = COPY $x0
26 ; DARWIN: %width:_(s64) = COPY $x1
27 ; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
28 ; DARWIN: RET_ReallyLR
29 ; UNKNOWN-LABEL: name: bzero_unknown_width
30 ; UNKNOWN: liveins: $x0, $x1
31 ; UNKNOWN: %ptr:_(p0) = COPY $x0
32 ; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
33 ; UNKNOWN: %width:_(s64) = COPY $x1
34 ; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
35 ; UNKNOWN: RET_ReallyLR
37 %zero:_(s8) = G_CONSTANT i8 0
38 %width:_(s64) = COPY $x1
39 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
43 name: bzero_tail_unknown_width
44 tracksRegLiveness: true
48 ; DARWIN-LABEL: name: bzero_tail_unknown_width
49 ; DARWIN: liveins: $x0, $x1
50 ; DARWIN: %ptr:_(p0) = COPY $x0
51 ; DARWIN: %width:_(s64) = COPY $x1
52 ; DARWIN: G_BZERO %ptr(p0), %width(s64), 1 :: (store (s32))
53 ; DARWIN: RET_ReallyLR
54 ; UNKNOWN-LABEL: name: bzero_tail_unknown_width
55 ; UNKNOWN: liveins: $x0, $x1
56 ; UNKNOWN: %ptr:_(p0) = COPY $x0
57 ; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
58 ; UNKNOWN: %width:_(s64) = COPY $x1
59 ; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
60 ; UNKNOWN: RET_ReallyLR
62 %zero:_(s8) = G_CONSTANT i8 0
63 %width:_(s64) = COPY $x1
64 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
68 name: bzero_constant_width
69 tracksRegLiveness: true
73 ; For values >256, we should use G_BZERO on Darwin.
75 ; DARWIN-LABEL: name: bzero_constant_width
76 ; DARWIN: liveins: $x0, $x1
77 ; DARWIN: %ptr:_(p0) = COPY $x0
78 ; DARWIN: %width:_(s64) = G_CONSTANT i64 1024
79 ; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
80 ; DARWIN: RET_ReallyLR
81 ; UNKNOWN-LABEL: name: bzero_constant_width
82 ; UNKNOWN: liveins: $x0, $x1
83 ; UNKNOWN: %ptr:_(p0) = COPY $x0
84 ; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
85 ; UNKNOWN: %width:_(s64) = G_CONSTANT i64 1024
86 ; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
87 ; UNKNOWN: RET_ReallyLR
89 %zero:_(s8) = G_CONSTANT i8 0
90 %width:_(s64) = G_CONSTANT i64 1024
91 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
95 name: bzero_constant_width_minsize
96 tracksRegLiveness: true
100 ; With minsize, we should always use G_BZERO to avoid a copy from wzr.
102 ; DARWIN-LABEL: name: bzero_constant_width_minsize
103 ; DARWIN: liveins: $x0, $x1
104 ; DARWIN: %ptr:_(p0) = COPY $x0
105 ; DARWIN: %width:_(s64) = G_CONSTANT i64 256
106 ; DARWIN: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
107 ; DARWIN: RET_ReallyLR
108 ; UNKNOWN-LABEL: name: bzero_constant_width_minsize
109 ; UNKNOWN: liveins: $x0, $x1
110 ; UNKNOWN: %ptr:_(p0) = COPY $x0
111 ; UNKNOWN: %zero:_(s8) = G_CONSTANT i8 0
112 ; UNKNOWN: %width:_(s64) = G_CONSTANT i64 256
113 ; UNKNOWN: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
114 ; UNKNOWN: RET_ReallyLR
115 %ptr:_(p0) = COPY $x0
116 %zero:_(s8) = G_CONSTANT i8 0
117 %width:_(s64) = G_CONSTANT i64 256
118 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
123 tracksRegLiveness: true
127 ; When the value isn't 0, don't create G_BZERO.
129 ; DARWIN-LABEL: name: not_zero
130 ; DARWIN: liveins: $x0, $x1
131 ; DARWIN: %ptr:_(p0) = COPY $x0
132 ; DARWIN: %not_zero:_(s8) = G_CONSTANT i8 1
133 ; DARWIN: %width:_(s64) = G_CONSTANT i64 256
134 ; DARWIN: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
135 ; DARWIN: RET_ReallyLR
136 ; UNKNOWN-LABEL: name: not_zero
137 ; UNKNOWN: liveins: $x0, $x1
138 ; UNKNOWN: %ptr:_(p0) = COPY $x0
139 ; UNKNOWN: %not_zero:_(s8) = G_CONSTANT i8 1
140 ; UNKNOWN: %width:_(s64) = G_CONSTANT i64 256
141 ; UNKNOWN: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
142 ; UNKNOWN: RET_ReallyLR
143 %ptr:_(p0) = COPY $x0
144 %not_zero:_(s8) = G_CONSTANT i8 1
145 %width:_(s64) = G_CONSTANT i64 256
146 G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))