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
26 ; DARWIN-NEXT: %ptr:_(p0) = COPY $x0
27 ; DARWIN-NEXT: %width:_(s64) = COPY $x1
28 ; DARWIN-NEXT: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
29 ; DARWIN-NEXT: RET_ReallyLR
31 ; UNKNOWN-LABEL: name: bzero_unknown_width
32 ; UNKNOWN: liveins: $x0, $x1
33 ; UNKNOWN-NEXT: {{ $}}
34 ; UNKNOWN-NEXT: %ptr:_(p0) = COPY $x0
35 ; UNKNOWN-NEXT: %zero:_(s8) = G_CONSTANT i8 0
36 ; UNKNOWN-NEXT: %width:_(s64) = COPY $x1
37 ; UNKNOWN-NEXT: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
38 ; UNKNOWN-NEXT: RET_ReallyLR
40 %zero:_(s8) = G_CONSTANT i8 0
41 %width:_(s64) = COPY $x1
42 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
46 name: bzero_tail_unknown_width
47 tracksRegLiveness: true
51 ; DARWIN-LABEL: name: bzero_tail_unknown_width
52 ; DARWIN: liveins: $x0, $x1
54 ; DARWIN-NEXT: %ptr:_(p0) = COPY $x0
55 ; DARWIN-NEXT: %width:_(s64) = COPY $x1
56 ; DARWIN-NEXT: G_BZERO %ptr(p0), %width(s64), 1 :: (store (s32))
57 ; DARWIN-NEXT: RET_ReallyLR
59 ; UNKNOWN-LABEL: name: bzero_tail_unknown_width
60 ; UNKNOWN: liveins: $x0, $x1
61 ; UNKNOWN-NEXT: {{ $}}
62 ; UNKNOWN-NEXT: %ptr:_(p0) = COPY $x0
63 ; UNKNOWN-NEXT: %zero:_(s8) = G_CONSTANT i8 0
64 ; UNKNOWN-NEXT: %width:_(s64) = COPY $x1
65 ; UNKNOWN-NEXT: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
66 ; UNKNOWN-NEXT: RET_ReallyLR
68 %zero:_(s8) = G_CONSTANT i8 0
69 %width:_(s64) = COPY $x1
70 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 1 :: (store (s32))
74 name: bzero_constant_width
75 tracksRegLiveness: true
79 ; For values >256, we should use G_BZERO on Darwin.
81 ; DARWIN-LABEL: name: bzero_constant_width
82 ; DARWIN: liveins: $x0, $x1
84 ; DARWIN-NEXT: %ptr:_(p0) = COPY $x0
85 ; DARWIN-NEXT: %width:_(s64) = G_CONSTANT i64 1024
86 ; DARWIN-NEXT: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
87 ; DARWIN-NEXT: RET_ReallyLR
89 ; UNKNOWN-LABEL: name: bzero_constant_width
90 ; UNKNOWN: liveins: $x0, $x1
91 ; UNKNOWN-NEXT: {{ $}}
92 ; UNKNOWN-NEXT: %ptr:_(p0) = COPY $x0
93 ; UNKNOWN-NEXT: %zero:_(s8) = G_CONSTANT i8 0
94 ; UNKNOWN-NEXT: %width:_(s64) = G_CONSTANT i64 1024
95 ; UNKNOWN-NEXT: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
96 ; UNKNOWN-NEXT: RET_ReallyLR
98 %zero:_(s8) = G_CONSTANT i8 0
99 %width:_(s64) = G_CONSTANT i64 1024
100 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
104 name: bzero_constant_width_minsize
105 tracksRegLiveness: true
109 ; With minsize, we should always use G_BZERO to avoid a copy from wzr.
111 ; DARWIN-LABEL: name: bzero_constant_width_minsize
112 ; DARWIN: liveins: $x0, $x1
113 ; DARWIN-NEXT: {{ $}}
114 ; DARWIN-NEXT: %ptr:_(p0) = COPY $x0
115 ; DARWIN-NEXT: %width:_(s64) = G_CONSTANT i64 256
116 ; DARWIN-NEXT: G_BZERO %ptr(p0), %width(s64), 0 :: (store (s32))
117 ; DARWIN-NEXT: RET_ReallyLR
119 ; UNKNOWN-LABEL: name: bzero_constant_width_minsize
120 ; UNKNOWN: liveins: $x0, $x1
121 ; UNKNOWN-NEXT: {{ $}}
122 ; UNKNOWN-NEXT: %ptr:_(p0) = COPY $x0
123 ; UNKNOWN-NEXT: %zero:_(s8) = G_CONSTANT i8 0
124 ; UNKNOWN-NEXT: %width:_(s64) = G_CONSTANT i64 256
125 ; UNKNOWN-NEXT: G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
126 ; UNKNOWN-NEXT: RET_ReallyLR
127 %ptr:_(p0) = COPY $x0
128 %zero:_(s8) = G_CONSTANT i8 0
129 %width:_(s64) = G_CONSTANT i64 256
130 G_MEMSET %ptr(p0), %zero(s8), %width(s64), 0 :: (store (s32))
135 tracksRegLiveness: true
139 ; When the value isn't 0, don't create G_BZERO.
141 ; DARWIN-LABEL: name: not_zero
142 ; DARWIN: liveins: $x0, $x1
143 ; DARWIN-NEXT: {{ $}}
144 ; DARWIN-NEXT: %ptr:_(p0) = COPY $x0
145 ; DARWIN-NEXT: %not_zero:_(s8) = G_CONSTANT i8 1
146 ; DARWIN-NEXT: %width:_(s64) = G_CONSTANT i64 256
147 ; DARWIN-NEXT: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
148 ; DARWIN-NEXT: RET_ReallyLR
150 ; UNKNOWN-LABEL: name: not_zero
151 ; UNKNOWN: liveins: $x0, $x1
152 ; UNKNOWN-NEXT: {{ $}}
153 ; UNKNOWN-NEXT: %ptr:_(p0) = COPY $x0
154 ; UNKNOWN-NEXT: %not_zero:_(s8) = G_CONSTANT i8 1
155 ; UNKNOWN-NEXT: %width:_(s64) = G_CONSTANT i64 256
156 ; UNKNOWN-NEXT: G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))
157 ; UNKNOWN-NEXT: RET_ReallyLR
158 %ptr:_(p0) = COPY $x0
159 %not_zero:_(s8) = G_CONSTANT i8 1
160 %width:_(s64) = G_CONSTANT i64 256
161 G_MEMSET %ptr(p0), %not_zero(s8), %width(s64), 0 :: (store (s32))