1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; Verify that calls to memchr with arrays of elements larger than char
3; are folded correctly.
4; RUN: opt < %s -passes=instcombine -S -data-layout="E" | FileCheck %s --check-prefixes=BE
5; RUN: opt < %s -passes=instcombine -S -data-layout="e" | FileCheck %s --check-prefixes=LE
6
7declare i8* @memchr(i8*, i32, i64)
8
9; BE representation: { 'a', 'b', 'c', 'd', 'e', ..., 'p' }
10; LE representation: { 'd', 'c', 'b', 'a', 'h', ..., 'm' }
11@a = constant [4 x i32] [i32 1633837924, i32 1701209960, i32 1768581996, i32 1835954032]
12
13
14; Fold memchr(a, C, 16) for C in ['a', 'd'] U ['o', 'q'].
15
16define void @fold_memchr_a(i64* %pcmp) {
17; BE-LABEL: @fold_memchr_a(
18; BE-NEXT:    [[PA:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 97, i64 16)
19; BE-NEXT:    [[IPA:%.*]] = ptrtoint i8* [[PA]] to i64
20; BE-NEXT:    [[OFFA:%.*]] = sub i64 [[IPA]], ptrtoint ([4 x i32]* @a to i64)
21; BE-NEXT:    store i64 [[OFFA]], i64* [[PCMP:%.*]], align 4
22; BE-NEXT:    [[PB:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 98, i64 16)
23; BE-NEXT:    [[IPB:%.*]] = ptrtoint i8* [[PB]] to i64
24; BE-NEXT:    [[OFFB:%.*]] = sub i64 [[IPB]], ptrtoint ([4 x i32]* @a to i64)
25; BE-NEXT:    [[PSTOR1:%.*]] = getelementptr i64, i64* [[PCMP]], i64 1
26; BE-NEXT:    store i64 [[OFFB]], i64* [[PSTOR1]], align 4
27; BE-NEXT:    [[PC:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 99, i64 16)
28; BE-NEXT:    [[IPC:%.*]] = ptrtoint i8* [[PC]] to i64
29; BE-NEXT:    [[OFFC:%.*]] = sub i64 [[IPC]], ptrtoint ([4 x i32]* @a to i64)
30; BE-NEXT:    [[PSTOR2:%.*]] = getelementptr i64, i64* [[PCMP]], i64 2
31; BE-NEXT:    store i64 [[OFFC]], i64* [[PSTOR2]], align 4
32; BE-NEXT:    [[PD:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 100, i64 16)
33; BE-NEXT:    [[IPD:%.*]] = ptrtoint i8* [[PD]] to i64
34; BE-NEXT:    [[OFFD:%.*]] = sub i64 [[IPD]], ptrtoint ([4 x i32]* @a to i64)
35; BE-NEXT:    [[PSTOR3:%.*]] = getelementptr i64, i64* [[PCMP]], i64 3
36; BE-NEXT:    store i64 [[OFFD]], i64* [[PSTOR3]], align 4
37; BE-NEXT:    [[PN:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 110, i64 16)
38; BE-NEXT:    [[IPN:%.*]] = ptrtoint i8* [[PN]] to i64
39; BE-NEXT:    [[OFFN:%.*]] = sub i64 [[IPN]], ptrtoint ([4 x i32]* @a to i64)
40; BE-NEXT:    [[PSTOR4:%.*]] = getelementptr i64, i64* [[PCMP]], i64 4
41; BE-NEXT:    store i64 [[OFFN]], i64* [[PSTOR4]], align 4
42; BE-NEXT:    [[PO:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 111, i64 16)
43; BE-NEXT:    [[IPO:%.*]] = ptrtoint i8* [[PO]] to i64
44; BE-NEXT:    [[OFFO:%.*]] = sub i64 [[IPO]], ptrtoint ([4 x i32]* @a to i64)
45; BE-NEXT:    [[PSTOR6:%.*]] = getelementptr i64, i64* [[PCMP]], i64 6
46; BE-NEXT:    store i64 [[OFFO]], i64* [[PSTOR6]], align 4
47; BE-NEXT:    [[PP:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 112, i64 16)
48; BE-NEXT:    [[IPP:%.*]] = ptrtoint i8* [[PP]] to i64
49; BE-NEXT:    [[OFFP:%.*]] = sub i64 [[IPP]], ptrtoint ([4 x i32]* @a to i64)
50; BE-NEXT:    [[PSTOR7:%.*]] = getelementptr i64, i64* [[PCMP]], i64 7
51; BE-NEXT:    store i64 [[OFFP]], i64* [[PSTOR7]], align 4
52; BE-NEXT:    [[PQ:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 113, i64 16)
53; BE-NEXT:    [[IPQ:%.*]] = ptrtoint i8* [[PQ]] to i64
54; BE-NEXT:    [[PSTOR8:%.*]] = getelementptr i64, i64* [[PCMP]], i64 8
55; BE-NEXT:    store i64 [[IPQ]], i64* [[PSTOR8]], align 4
56; BE-NEXT:    ret void
57;
58; LE-LABEL: @fold_memchr_a(
59; LE-NEXT:    [[PA:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 97, i64 16)
60; LE-NEXT:    [[IPA:%.*]] = ptrtoint i8* [[PA]] to i64
61; LE-NEXT:    [[OFFA:%.*]] = sub i64 [[IPA]], ptrtoint ([4 x i32]* @a to i64)
62; LE-NEXT:    store i64 [[OFFA]], i64* [[PCMP:%.*]], align 4
63; LE-NEXT:    [[PB:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 98, i64 16)
64; LE-NEXT:    [[IPB:%.*]] = ptrtoint i8* [[PB]] to i64
65; LE-NEXT:    [[OFFB:%.*]] = sub i64 [[IPB]], ptrtoint ([4 x i32]* @a to i64)
66; LE-NEXT:    [[PSTOR1:%.*]] = getelementptr i64, i64* [[PCMP]], i64 1
67; LE-NEXT:    store i64 [[OFFB]], i64* [[PSTOR1]], align 4
68; LE-NEXT:    [[PC:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 99, i64 16)
69; LE-NEXT:    [[IPC:%.*]] = ptrtoint i8* [[PC]] to i64
70; LE-NEXT:    [[OFFC:%.*]] = sub i64 [[IPC]], ptrtoint ([4 x i32]* @a to i64)
71; LE-NEXT:    [[PSTOR2:%.*]] = getelementptr i64, i64* [[PCMP]], i64 2
72; LE-NEXT:    store i64 [[OFFC]], i64* [[PSTOR2]], align 4
73; LE-NEXT:    [[PD:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 100, i64 16)
74; LE-NEXT:    [[IPD:%.*]] = ptrtoint i8* [[PD]] to i64
75; LE-NEXT:    [[OFFD:%.*]] = sub i64 [[IPD]], ptrtoint ([4 x i32]* @a to i64)
76; LE-NEXT:    [[PSTOR3:%.*]] = getelementptr i64, i64* [[PCMP]], i64 3
77; LE-NEXT:    store i64 [[OFFD]], i64* [[PSTOR3]], align 4
78; LE-NEXT:    [[PN:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 110, i64 16)
79; LE-NEXT:    [[IPN:%.*]] = ptrtoint i8* [[PN]] to i64
80; LE-NEXT:    [[OFFN:%.*]] = sub i64 [[IPN]], ptrtoint ([4 x i32]* @a to i64)
81; LE-NEXT:    [[PSTOR4:%.*]] = getelementptr i64, i64* [[PCMP]], i64 4
82; LE-NEXT:    store i64 [[OFFN]], i64* [[PSTOR4]], align 4
83; LE-NEXT:    [[PO:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 111, i64 16)
84; LE-NEXT:    [[IPO:%.*]] = ptrtoint i8* [[PO]] to i64
85; LE-NEXT:    [[OFFO:%.*]] = sub i64 [[IPO]], ptrtoint ([4 x i32]* @a to i64)
86; LE-NEXT:    [[PSTOR6:%.*]] = getelementptr i64, i64* [[PCMP]], i64 6
87; LE-NEXT:    store i64 [[OFFO]], i64* [[PSTOR6]], align 4
88; LE-NEXT:    [[PP:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 112, i64 16)
89; LE-NEXT:    [[IPP:%.*]] = ptrtoint i8* [[PP]] to i64
90; LE-NEXT:    [[OFFP:%.*]] = sub i64 [[IPP]], ptrtoint ([4 x i32]* @a to i64)
91; LE-NEXT:    [[PSTOR7:%.*]] = getelementptr i64, i64* [[PCMP]], i64 7
92; LE-NEXT:    store i64 [[OFFP]], i64* [[PSTOR7]], align 4
93; LE-NEXT:    [[PQ:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast ([4 x i32]* @a to i8*), i32 113, i64 16)
94; LE-NEXT:    [[IPQ:%.*]] = ptrtoint i8* [[PQ]] to i64
95; LE-NEXT:    [[PSTOR8:%.*]] = getelementptr i64, i64* [[PCMP]], i64 8
96; LE-NEXT:    store i64 [[IPQ]], i64* [[PSTOR8]], align 4
97; LE-NEXT:    ret void
98;
99  %p0 = getelementptr [4 x i32], [4 x i32]* @a, i64 0, i64 0
100  %p1 = bitcast i32* %p0 to i8*
101  %ip0 = ptrtoint [4 x i32]* @a to i64
102
103; Fold memchr(a, 'a', 16) - a to 0 (3 in LE).
104
105  %pa = call i8* @memchr(i8* %p1, i32 97, i64 16)
106  %ipa = ptrtoint i8* %pa to i64
107  %offa = sub i64 %ipa, %ip0
108  %pstor0 = getelementptr i64, i64* %pcmp, i64 0
109  store i64 %offa, i64* %pstor0
110
111; Fold memchr(a, 'b', 16) - a to 1 (2 in LE)
112
113  %pb = call i8* @memchr(i8* %p1, i32 98, i64 16)
114  %ipb = ptrtoint i8* %pb to i64
115  %offb = sub i64 %ipb, %ip0
116  %pstor1 = getelementptr i64, i64* %pcmp, i64 1
117  store i64 %offb, i64* %pstor1
118
119; Fold memchr(a, 'c', 16) - a to 2 (1 in LE)
120
121  %pc = call i8* @memchr(i8* %p1, i32 99, i64 16)
122  %ipc = ptrtoint i8* %pc to i64
123  %offc = sub i64 %ipc, %ip0
124  %pstor2 = getelementptr i64, i64* %pcmp, i64 2
125  store i64 %offc, i64* %pstor2
126
127; Fold memchr(a, 'd', 16) - a to 3 (0 in LE)
128
129  %pd = call i8* @memchr(i8* %p1, i32 100, i64 16)
130  %ipd = ptrtoint i8* %pd to i64
131  %offd = sub i64 %ipd, %ip0
132  %pstor3 = getelementptr i64, i64* %pcmp, i64 3
133  store i64 %offd, i64* %pstor3
134
135; Fold memchr(a, 'n', 16) - a to 13 (14 in LE)
136
137  %pn = call i8* @memchr(i8* %p1, i32 110, i64 16)
138  %ipn = ptrtoint i8* %pn to i64
139  %offn = sub i64 %ipn, %ip0
140  %pstor4 = getelementptr i64, i64* %pcmp, i64 4
141  store i64 %offn, i64* %pstor4
142
143; Fold memchr(a, 'o', 16) - a to 14 (13 in LE)
144
145  %po = call i8* @memchr(i8* %p1, i32 111, i64 16)
146  %ipo = ptrtoint i8* %po to i64
147  %offo = sub i64 %ipo, %ip0
148  %pstor6 = getelementptr i64, i64* %pcmp, i64 6
149  store i64 %offo, i64* %pstor6
150
151; Fold memchr(a, 'p', 16) - a to 15 (12 in LE)
152
153  %pp = call i8* @memchr(i8* %p1, i32 112, i64 16)
154  %ipp = ptrtoint i8* %pp to i64
155  %offp = sub i64 %ipp, %ip0
156  %pstor7 = getelementptr i64, i64* %pcmp, i64 7
157  store i64 %offp, i64* %pstor7
158
159; Fold memchr(a, 'q', 16) to null in both BE and LE.
160
161  %pq = call i8* @memchr(i8* %p1, i32 113, i64 16)
162  %ipq = ptrtoint i8* %pq to i64
163  %pstor8 = getelementptr i64, i64* %pcmp, i64 8
164  store i64 %ipq, i64* %pstor8
165
166  ret void
167}
168
169
170; Fold memchr(a + 1, C, 12) for C in ['e', 'h'] U ['a', 'd'].
171
172define void @fold_memchr_a_p1(i64* %pcmp) {
173; BE-LABEL: @fold_memchr_a_p1(
174; BE-NEXT:    [[PE:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 101, i64 12)
175; BE-NEXT:    [[IPE:%.*]] = ptrtoint i8* [[PE]] to i64
176; BE-NEXT:    [[OFFE:%.*]] = sub i64 [[IPE]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
177; BE-NEXT:    store i64 [[OFFE]], i64* [[PCMP:%.*]], align 4
178; BE-NEXT:    [[PF:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 102, i64 12)
179; BE-NEXT:    [[IPF:%.*]] = ptrtoint i8* [[PF]] to i64
180; BE-NEXT:    [[OFFF:%.*]] = sub i64 [[IPF]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
181; BE-NEXT:    [[PSTOR1:%.*]] = getelementptr i64, i64* [[PCMP]], i64 1
182; BE-NEXT:    store i64 [[OFFF]], i64* [[PSTOR1]], align 4
183; BE-NEXT:    [[PG:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 103, i64 12)
184; BE-NEXT:    [[IPG:%.*]] = ptrtoint i8* [[PG]] to i64
185; BE-NEXT:    [[OFFG:%.*]] = sub i64 [[IPG]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
186; BE-NEXT:    [[PSTOR2:%.*]] = getelementptr i64, i64* [[PCMP]], i64 2
187; BE-NEXT:    store i64 [[OFFG]], i64* [[PSTOR2]], align 4
188; BE-NEXT:    [[PH:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 104, i64 12)
189; BE-NEXT:    [[IPH:%.*]] = ptrtoint i8* [[PH]] to i64
190; BE-NEXT:    [[OFFH:%.*]] = sub i64 [[IPH]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
191; BE-NEXT:    [[PSTOR3:%.*]] = getelementptr i64, i64* [[PCMP]], i64 3
192; BE-NEXT:    store i64 [[OFFH]], i64* [[PSTOR3]], align 4
193; BE-NEXT:    [[PA:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 97, i64 12)
194; BE-NEXT:    [[IPA:%.*]] = ptrtoint i8* [[PA]] to i64
195; BE-NEXT:    [[PSTOR4:%.*]] = getelementptr i64, i64* [[PCMP]], i64 4
196; BE-NEXT:    store i64 [[IPA]], i64* [[PSTOR4]], align 4
197; BE-NEXT:    [[PD:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 100, i64 12)
198; BE-NEXT:    [[IPD:%.*]] = ptrtoint i8* [[PD]] to i64
199; BE-NEXT:    [[PSTOR5:%.*]] = getelementptr i64, i64* [[PCMP]], i64 5
200; BE-NEXT:    store i64 [[IPD]], i64* [[PSTOR5]], align 4
201; BE-NEXT:    ret void
202;
203; LE-LABEL: @fold_memchr_a_p1(
204; LE-NEXT:    [[PE:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 101, i64 12)
205; LE-NEXT:    [[IPE:%.*]] = ptrtoint i8* [[PE]] to i64
206; LE-NEXT:    [[OFFE:%.*]] = sub i64 [[IPE]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
207; LE-NEXT:    store i64 [[OFFE]], i64* [[PCMP:%.*]], align 4
208; LE-NEXT:    [[PF:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 102, i64 12)
209; LE-NEXT:    [[IPF:%.*]] = ptrtoint i8* [[PF]] to i64
210; LE-NEXT:    [[OFFF:%.*]] = sub i64 [[IPF]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
211; LE-NEXT:    [[PSTOR1:%.*]] = getelementptr i64, i64* [[PCMP]], i64 1
212; LE-NEXT:    store i64 [[OFFF]], i64* [[PSTOR1]], align 4
213; LE-NEXT:    [[PG:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 103, i64 12)
214; LE-NEXT:    [[IPG:%.*]] = ptrtoint i8* [[PG]] to i64
215; LE-NEXT:    [[OFFG:%.*]] = sub i64 [[IPG]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
216; LE-NEXT:    [[PSTOR2:%.*]] = getelementptr i64, i64* [[PCMP]], i64 2
217; LE-NEXT:    store i64 [[OFFG]], i64* [[PSTOR2]], align 4
218; LE-NEXT:    [[PH:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 104, i64 12)
219; LE-NEXT:    [[IPH:%.*]] = ptrtoint i8* [[PH]] to i64
220; LE-NEXT:    [[OFFH:%.*]] = sub i64 [[IPH]], ptrtoint (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i64)
221; LE-NEXT:    [[PSTOR3:%.*]] = getelementptr i64, i64* [[PCMP]], i64 3
222; LE-NEXT:    store i64 [[OFFH]], i64* [[PSTOR3]], align 4
223; LE-NEXT:    [[PA:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 97, i64 12)
224; LE-NEXT:    [[IPA:%.*]] = ptrtoint i8* [[PA]] to i64
225; LE-NEXT:    [[PSTOR4:%.*]] = getelementptr i64, i64* [[PCMP]], i64 4
226; LE-NEXT:    store i64 [[IPA]], i64* [[PSTOR4]], align 4
227; LE-NEXT:    [[PD:%.*]] = call i8* @memchr(i8* noundef nonnull dereferenceable(1) bitcast (i32* getelementptr inbounds ([4 x i32], [4 x i32]* @a, i64 0, i64 1) to i8*), i32 100, i64 12)
228; LE-NEXT:    [[IPD:%.*]] = ptrtoint i8* [[PD]] to i64
229; LE-NEXT:    [[PSTOR5:%.*]] = getelementptr i64, i64* [[PCMP]], i64 5
230; LE-NEXT:    store i64 [[IPD]], i64* [[PSTOR5]], align 4
231; LE-NEXT:    ret void
232;
233  %p0 = getelementptr [4 x i32], [4 x i32]* @a, i64 0, i64 1
234  %p1 = bitcast i32* %p0 to i8*
235  %ip0 = ptrtoint i8* %p1 to i64
236
237; Fold memchr(a + 1, 'e', 12) - a to 0 (3 in LE).
238
239  %pe = call i8* @memchr(i8* %p1, i32 101, i64 12)
240  %ipe = ptrtoint i8* %pe to i64
241  %offe = sub i64 %ipe, %ip0
242  %pstor0 = getelementptr i64, i64* %pcmp, i64 0
243  store i64 %offe, i64* %pstor0
244
245; Fold memchr(a + 1, 'f', 12) - a to 1 (2 in LE).
246
247  %pf = call i8* @memchr(i8* %p1, i32 102, i64 12)
248  %ipf = ptrtoint i8* %pf to i64
249  %offf = sub i64 %ipf, %ip0
250  %pstor1 = getelementptr i64, i64* %pcmp, i64 1
251  store i64 %offf, i64* %pstor1
252
253; Fold memchr(a + 1, 'g', 12) - a to 2 (1 in LE).
254
255  %pg = call i8* @memchr(i8* %p1, i32 103, i64 12)
256  %ipg = ptrtoint i8* %pg to i64
257  %offg = sub i64 %ipg, %ip0
258  %pstor2 = getelementptr i64, i64* %pcmp, i64 2
259  store i64 %offg, i64* %pstor2
260
261; Fold memchr(a + 1, 'h', 12) - a to 3 (0 in LE).
262
263  %ph = call i8* @memchr(i8* %p1, i32 104, i64 12)
264  %iph = ptrtoint i8* %ph to i64
265  %offh = sub i64 %iph, %ip0
266  %pstor3 = getelementptr i64, i64* %pcmp, i64 3
267  store i64 %offh, i64* %pstor3
268
269; Fold memchr(a + 1, 'a', 12) to null in both BE and LE.
270
271  %pa = call i8* @memchr(i8* %p1, i32 97, i64 12)
272  %ipa = ptrtoint i8* %pa to i64
273  %pstor4 = getelementptr i64, i64* %pcmp, i64 4
274  store i64 %ipa, i64* %pstor4
275
276; Fold memchr(a + 1, 'd', 12) to null in both BE and LE.
277
278  %pd = call i8* @memchr(i8* %p1, i32 100, i64 12)
279  %ipd = ptrtoint i8* %pd to i64
280  %pstor5 = getelementptr i64, i64* %pcmp, i64 5
281  store i64 %ipd, i64* %pstor5
282
283  ret void
284}
285