• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc -mtriple=x86_64-- < %s -pre-RA-sched=list-ilp    | FileCheck %s --check-prefix=ILP
3; RUN: llc -mtriple=x86_64-- < %s -pre-RA-sched=list-hybrid | FileCheck %s --check-prefix=HYBRID
4; RUN: llc -mtriple=x86_64-- < %s -pre-RA-sched=list-burr   | FileCheck %s --check-prefix=BURR
5; RUN: llc -mtriple=x86_64-- < %s -pre-RA-sched=source      | FileCheck %s --check-prefix=SRC
6; FIXME: Fix machine verifier issues and remove -verify-machineinstrs=0. PR39452.
7; RUN: llc -mtriple=x86_64-- < %s -pre-RA-sched=linearize -verify-machineinstrs=0 | FileCheck %s --check-prefix=LIN
8
9; PR22304 https://llvm.org/bugs/show_bug.cgi?id=22304
10; Tests checking backtracking in source scheduler. llc used to crash on them.
11
12define i256 @test1(i256 %a) nounwind {
13; ILP-LABEL: test1:
14; ILP:       # %bb.0:
15; ILP-NEXT:    pushq %r14
16; ILP-NEXT:    pushq %rbx
17; ILP-NEXT:    movq %rdi, %rax
18; ILP-NEXT:    xorl %r8d, %r8d
19; ILP-NEXT:    addl %esi, %esi
20; ILP-NEXT:    leal 3(%rsi), %r9d
21; ILP-NEXT:    movb $125, %r10b
22; ILP-NEXT:    movl $1, %edi
23; ILP-NEXT:    xorl %r11d, %r11d
24; ILP-NEXT:    movl %r9d, %ecx
25; ILP-NEXT:    shldq %cl, %rdi, %r11
26; ILP-NEXT:    subb %sil, %r10b
27; ILP-NEXT:    addb $-125, %sil
28; ILP-NEXT:    xorl %ebx, %ebx
29; ILP-NEXT:    movl %esi, %ecx
30; ILP-NEXT:    shldq %cl, %rdi, %rbx
31; ILP-NEXT:    movl $1, %edx
32; ILP-NEXT:    shlq %cl, %rdx
33; ILP-NEXT:    movl $1, %r14d
34; ILP-NEXT:    movl %r10d, %ecx
35; ILP-NEXT:    shrdq %cl, %r8, %r14
36; ILP-NEXT:    movl %r9d, %ecx
37; ILP-NEXT:    shlq %cl, %rdi
38; ILP-NEXT:    testb $64, %r9b
39; ILP-NEXT:    cmovneq %rdi, %r11
40; ILP-NEXT:    cmovneq %r8, %rdi
41; ILP-NEXT:    testb $64, %r10b
42; ILP-NEXT:    cmovneq %r8, %r14
43; ILP-NEXT:    testb $64, %sil
44; ILP-NEXT:    cmovneq %rdx, %rbx
45; ILP-NEXT:    cmovneq %r8, %rdx
46; ILP-NEXT:    testb %r9b, %r9b
47; ILP-NEXT:    cmovsq %r8, %r11
48; ILP-NEXT:    cmovsq %r8, %rdi
49; ILP-NEXT:    movq %r11, 8(%rax)
50; ILP-NEXT:    movq %rdi, (%rax)
51; ILP-NEXT:    cmovnsq %r8, %rbx
52; ILP-NEXT:    cmoveq %r8, %rbx
53; ILP-NEXT:    movq %rbx, 24(%rax)
54; ILP-NEXT:    cmovnsq %r14, %rdx
55; ILP-NEXT:    cmoveq %r8, %rdx
56; ILP-NEXT:    movq %rdx, 16(%rax)
57; ILP-NEXT:    popq %rbx
58; ILP-NEXT:    popq %r14
59; ILP-NEXT:    retq
60;
61; HYBRID-LABEL: test1:
62; HYBRID:       # %bb.0:
63; HYBRID-NEXT:    pushq %rbx
64; HYBRID-NEXT:    movq %rdi, %rax
65; HYBRID-NEXT:    addl %esi, %esi
66; HYBRID-NEXT:    movb $125, %cl
67; HYBRID-NEXT:    subb %sil, %cl
68; HYBRID-NEXT:    xorl %r8d, %r8d
69; HYBRID-NEXT:    movl $1, %edi
70; HYBRID-NEXT:    movl $1, %r9d
71; HYBRID-NEXT:    shrdq %cl, %r8, %r9
72; HYBRID-NEXT:    testb $64, %cl
73; HYBRID-NEXT:    cmovneq %r8, %r9
74; HYBRID-NEXT:    leal 3(%rsi), %r10d
75; HYBRID-NEXT:    xorl %r11d, %r11d
76; HYBRID-NEXT:    movl %r10d, %ecx
77; HYBRID-NEXT:    shldq %cl, %rdi, %r11
78; HYBRID-NEXT:    addb $-125, %sil
79; HYBRID-NEXT:    xorl %edx, %edx
80; HYBRID-NEXT:    movl %esi, %ecx
81; HYBRID-NEXT:    shldq %cl, %rdi, %rdx
82; HYBRID-NEXT:    movl $1, %ebx
83; HYBRID-NEXT:    shlq %cl, %rbx
84; HYBRID-NEXT:    testb $64, %sil
85; HYBRID-NEXT:    cmovneq %rbx, %rdx
86; HYBRID-NEXT:    cmovneq %r8, %rbx
87; HYBRID-NEXT:    movl %r10d, %ecx
88; HYBRID-NEXT:    shlq %cl, %rdi
89; HYBRID-NEXT:    testb $64, %r10b
90; HYBRID-NEXT:    cmovneq %rdi, %r11
91; HYBRID-NEXT:    cmovneq %r8, %rdi
92; HYBRID-NEXT:    testb %r10b, %r10b
93; HYBRID-NEXT:    cmovsq %r8, %r11
94; HYBRID-NEXT:    movq %r11, 8(%rax)
95; HYBRID-NEXT:    cmovsq %r8, %rdi
96; HYBRID-NEXT:    movq %rdi, (%rax)
97; HYBRID-NEXT:    cmovnsq %r8, %rdx
98; HYBRID-NEXT:    cmoveq %r8, %rdx
99; HYBRID-NEXT:    movq %rdx, 24(%rax)
100; HYBRID-NEXT:    cmovnsq %r9, %rbx
101; HYBRID-NEXT:    cmoveq %r8, %rbx
102; HYBRID-NEXT:    movq %rbx, 16(%rax)
103; HYBRID-NEXT:    popq %rbx
104; HYBRID-NEXT:    retq
105;
106; BURR-LABEL: test1:
107; BURR:       # %bb.0:
108; BURR-NEXT:    pushq %rbx
109; BURR-NEXT:    movq %rdi, %rax
110; BURR-NEXT:    addl %esi, %esi
111; BURR-NEXT:    movb $125, %cl
112; BURR-NEXT:    subb %sil, %cl
113; BURR-NEXT:    xorl %r8d, %r8d
114; BURR-NEXT:    movl $1, %edi
115; BURR-NEXT:    movl $1, %r9d
116; BURR-NEXT:    shrdq %cl, %r8, %r9
117; BURR-NEXT:    testb $64, %cl
118; BURR-NEXT:    cmovneq %r8, %r9
119; BURR-NEXT:    leal 3(%rsi), %r10d
120; BURR-NEXT:    xorl %r11d, %r11d
121; BURR-NEXT:    movl %r10d, %ecx
122; BURR-NEXT:    shldq %cl, %rdi, %r11
123; BURR-NEXT:    addb $-125, %sil
124; BURR-NEXT:    xorl %edx, %edx
125; BURR-NEXT:    movl %esi, %ecx
126; BURR-NEXT:    shldq %cl, %rdi, %rdx
127; BURR-NEXT:    movl $1, %ebx
128; BURR-NEXT:    shlq %cl, %rbx
129; BURR-NEXT:    testb $64, %sil
130; BURR-NEXT:    cmovneq %rbx, %rdx
131; BURR-NEXT:    cmovneq %r8, %rbx
132; BURR-NEXT:    movl %r10d, %ecx
133; BURR-NEXT:    shlq %cl, %rdi
134; BURR-NEXT:    testb $64, %r10b
135; BURR-NEXT:    cmovneq %rdi, %r11
136; BURR-NEXT:    cmovneq %r8, %rdi
137; BURR-NEXT:    testb %r10b, %r10b
138; BURR-NEXT:    cmovsq %r8, %r11
139; BURR-NEXT:    movq %r11, 8(%rax)
140; BURR-NEXT:    cmovsq %r8, %rdi
141; BURR-NEXT:    movq %rdi, (%rax)
142; BURR-NEXT:    cmovnsq %r8, %rdx
143; BURR-NEXT:    cmoveq %r8, %rdx
144; BURR-NEXT:    movq %rdx, 24(%rax)
145; BURR-NEXT:    cmovnsq %r9, %rbx
146; BURR-NEXT:    cmoveq %r8, %rbx
147; BURR-NEXT:    movq %rbx, 16(%rax)
148; BURR-NEXT:    popq %rbx
149; BURR-NEXT:    retq
150;
151; SRC-LABEL: test1:
152; SRC:       # %bb.0:
153; SRC-NEXT:    pushq %rbx
154; SRC-NEXT:    movq %rdi, %rax
155; SRC-NEXT:    addl %esi, %esi
156; SRC-NEXT:    leal 3(%rsi), %r9d
157; SRC-NEXT:    movb $125, %cl
158; SRC-NEXT:    subb %sil, %cl
159; SRC-NEXT:    xorl %r8d, %r8d
160; SRC-NEXT:    movl $1, %edi
161; SRC-NEXT:    movl $1, %r10d
162; SRC-NEXT:    shrdq %cl, %r8, %r10
163; SRC-NEXT:    testb $64, %cl
164; SRC-NEXT:    cmovneq %r8, %r10
165; SRC-NEXT:    addb $-125, %sil
166; SRC-NEXT:    xorl %edx, %edx
167; SRC-NEXT:    movl %esi, %ecx
168; SRC-NEXT:    shldq %cl, %rdi, %rdx
169; SRC-NEXT:    xorl %r11d, %r11d
170; SRC-NEXT:    movl %r9d, %ecx
171; SRC-NEXT:    shldq %cl, %rdi, %r11
172; SRC-NEXT:    movl $1, %ebx
173; SRC-NEXT:    shlq %cl, %rbx
174; SRC-NEXT:    testb $64, %r9b
175; SRC-NEXT:    cmovneq %rbx, %r11
176; SRC-NEXT:    cmovneq %r8, %rbx
177; SRC-NEXT:    movl %esi, %ecx
178; SRC-NEXT:    shlq %cl, %rdi
179; SRC-NEXT:    testb $64, %sil
180; SRC-NEXT:    cmovneq %rdi, %rdx
181; SRC-NEXT:    cmovneq %r8, %rdi
182; SRC-NEXT:    testb %r9b, %r9b
183; SRC-NEXT:    cmovnsq %r10, %rdi
184; SRC-NEXT:    cmoveq %r8, %rdi
185; SRC-NEXT:    cmovnsq %r8, %rdx
186; SRC-NEXT:    cmoveq %r8, %rdx
187; SRC-NEXT:    cmovsq %r8, %r11
188; SRC-NEXT:    cmovsq %r8, %rbx
189; SRC-NEXT:    movq %r11, 8(%rax)
190; SRC-NEXT:    movq %rbx, (%rax)
191; SRC-NEXT:    movq %rdx, 24(%rax)
192; SRC-NEXT:    movq %rdi, 16(%rax)
193; SRC-NEXT:    popq %rbx
194; SRC-NEXT:    retq
195;
196; LIN-LABEL: test1:
197; LIN:       # %bb.0:
198; LIN-NEXT:    movq %rdi, %rax
199; LIN-NEXT:    xorl %r9d, %r9d
200; LIN-NEXT:    movl $1, %r8d
201; LIN-NEXT:    addl %esi, %esi
202; LIN-NEXT:    leal 3(%rsi), %ecx
203; LIN-NEXT:    movl $1, %edi
204; LIN-NEXT:    shlq %cl, %rdi
205; LIN-NEXT:    testb $64, %cl
206; LIN-NEXT:    movq %rdi, %rdx
207; LIN-NEXT:    cmovneq %r9, %rdx
208; LIN-NEXT:    testb %cl, %cl
209; LIN-NEXT:    cmovsq %r9, %rdx
210; LIN-NEXT:    movq %rdx, (%rax)
211; LIN-NEXT:    xorl %edx, %edx
212; LIN-NEXT:    # kill: def $cl killed $cl killed $ecx
213; LIN-NEXT:    shldq %cl, %r8, %rdx
214; LIN-NEXT:    cmovneq %rdi, %rdx
215; LIN-NEXT:    cmovsq %r9, %rdx
216; LIN-NEXT:    movq %rdx, 8(%rax)
217; LIN-NEXT:    leal -125(%rsi), %r10d
218; LIN-NEXT:    movl $1, %edx
219; LIN-NEXT:    movl %r10d, %ecx
220; LIN-NEXT:    shlq %cl, %rdx
221; LIN-NEXT:    testb $64, %r10b
222; LIN-NEXT:    movq %rdx, %rdi
223; LIN-NEXT:    cmovneq %r9, %rdi
224; LIN-NEXT:    movb $125, %cl
225; LIN-NEXT:    subb %sil, %cl
226; LIN-NEXT:    movl $1, %esi
227; LIN-NEXT:    shrdq %cl, %r9, %rsi
228; LIN-NEXT:    testb $64, %cl
229; LIN-NEXT:    cmovneq %r9, %rsi
230; LIN-NEXT:    cmovsq %rdi, %rsi
231; LIN-NEXT:    cmoveq %r9, %rsi
232; LIN-NEXT:    movq %rsi, 16(%rax)
233; LIN-NEXT:    xorl %esi, %esi
234; LIN-NEXT:    movl %r10d, %ecx
235; LIN-NEXT:    shldq %cl, %r8, %rsi
236; LIN-NEXT:    cmovneq %rdx, %rsi
237; LIN-NEXT:    cmovnsq %r9, %rsi
238; LIN-NEXT:    cmoveq %r9, %rsi
239; LIN-NEXT:    movq %rsi, 24(%rax)
240; LIN-NEXT:    retq
241  %b = add i256 %a, 1
242  %m = shl i256 %b, 1
243  %p = add i256 %m, 1
244  %v = lshr i256 %b, %p
245  %t = trunc i256 %v to i1
246  %c = shl i256 1, %p
247  %f = select i1 %t, i256 undef, i256 %c
248  ret i256 %f
249}
250
251define i256 @test2(i256 %a) nounwind {
252; ILP-LABEL: test2:
253; ILP:       # %bb.0:
254; ILP-NEXT:    movq %rdi, %rax
255; ILP-NEXT:    xorl %edi, %edi
256; ILP-NEXT:    movq %rsi, %r11
257; ILP-NEXT:    negq %r11
258; ILP-NEXT:    movl $0, %r10d
259; ILP-NEXT:    sbbq %rdx, %r10
260; ILP-NEXT:    movl $0, %r9d
261; ILP-NEXT:    sbbq %rcx, %r9
262; ILP-NEXT:    sbbq %r8, %rdi
263; ILP-NEXT:    andq %rcx, %r9
264; ILP-NEXT:    bsrq %r9, %rcx
265; ILP-NEXT:    xorq $63, %rcx
266; ILP-NEXT:    andq %r8, %rdi
267; ILP-NEXT:    bsrq %rdi, %r8
268; ILP-NEXT:    andq %rdx, %r10
269; ILP-NEXT:    bsrq %r10, %rdx
270; ILP-NEXT:    xorq $63, %r8
271; ILP-NEXT:    addq $64, %rcx
272; ILP-NEXT:    testq %rdi, %rdi
273; ILP-NEXT:    movq $0, 24(%rax)
274; ILP-NEXT:    movq $0, 16(%rax)
275; ILP-NEXT:    movq $0, 8(%rax)
276; ILP-NEXT:    cmovneq %r8, %rcx
277; ILP-NEXT:    xorq $63, %rdx
278; ILP-NEXT:    andq %rsi, %r11
279; ILP-NEXT:    movl $127, %r8d
280; ILP-NEXT:    bsrq %r11, %rsi
281; ILP-NEXT:    cmoveq %r8, %rsi
282; ILP-NEXT:    xorq $63, %rsi
283; ILP-NEXT:    addq $64, %rsi
284; ILP-NEXT:    testq %r10, %r10
285; ILP-NEXT:    cmovneq %rdx, %rsi
286; ILP-NEXT:    subq $-128, %rsi
287; ILP-NEXT:    orq %r9, %rdi
288; ILP-NEXT:    cmovneq %rcx, %rsi
289; ILP-NEXT:    movq %rsi, (%rax)
290; ILP-NEXT:    retq
291;
292; HYBRID-LABEL: test2:
293; HYBRID:       # %bb.0:
294; HYBRID-NEXT:    movq %rdi, %rax
295; HYBRID-NEXT:    xorl %r9d, %r9d
296; HYBRID-NEXT:    movq %rsi, %r11
297; HYBRID-NEXT:    negq %r11
298; HYBRID-NEXT:    movl $0, %r10d
299; HYBRID-NEXT:    sbbq %rdx, %r10
300; HYBRID-NEXT:    movl $0, %edi
301; HYBRID-NEXT:    sbbq %rcx, %rdi
302; HYBRID-NEXT:    sbbq %r8, %r9
303; HYBRID-NEXT:    andq %r8, %r9
304; HYBRID-NEXT:    bsrq %r9, %r8
305; HYBRID-NEXT:    xorq $63, %r8
306; HYBRID-NEXT:    andq %rcx, %rdi
307; HYBRID-NEXT:    bsrq %rdi, %rcx
308; HYBRID-NEXT:    xorq $63, %rcx
309; HYBRID-NEXT:    addq $64, %rcx
310; HYBRID-NEXT:    testq %r9, %r9
311; HYBRID-NEXT:    cmovneq %r8, %rcx
312; HYBRID-NEXT:    andq %rdx, %r10
313; HYBRID-NEXT:    bsrq %r10, %rdx
314; HYBRID-NEXT:    xorq $63, %rdx
315; HYBRID-NEXT:    andq %rsi, %r11
316; HYBRID-NEXT:    movl $127, %r8d
317; HYBRID-NEXT:    bsrq %r11, %rsi
318; HYBRID-NEXT:    cmoveq %r8, %rsi
319; HYBRID-NEXT:    xorq $63, %rsi
320; HYBRID-NEXT:    addq $64, %rsi
321; HYBRID-NEXT:    testq %r10, %r10
322; HYBRID-NEXT:    cmovneq %rdx, %rsi
323; HYBRID-NEXT:    subq $-128, %rsi
324; HYBRID-NEXT:    orq %r9, %rdi
325; HYBRID-NEXT:    cmovneq %rcx, %rsi
326; HYBRID-NEXT:    movq %rsi, (%rax)
327; HYBRID-NEXT:    movq $0, 24(%rax)
328; HYBRID-NEXT:    movq $0, 16(%rax)
329; HYBRID-NEXT:    movq $0, 8(%rax)
330; HYBRID-NEXT:    retq
331;
332; BURR-LABEL: test2:
333; BURR:       # %bb.0:
334; BURR-NEXT:    movq %rdi, %rax
335; BURR-NEXT:    xorl %r9d, %r9d
336; BURR-NEXT:    movq %rsi, %r11
337; BURR-NEXT:    negq %r11
338; BURR-NEXT:    movl $0, %r10d
339; BURR-NEXT:    sbbq %rdx, %r10
340; BURR-NEXT:    movl $0, %edi
341; BURR-NEXT:    sbbq %rcx, %rdi
342; BURR-NEXT:    sbbq %r8, %r9
343; BURR-NEXT:    andq %r8, %r9
344; BURR-NEXT:    bsrq %r9, %r8
345; BURR-NEXT:    xorq $63, %r8
346; BURR-NEXT:    andq %rcx, %rdi
347; BURR-NEXT:    bsrq %rdi, %rcx
348; BURR-NEXT:    xorq $63, %rcx
349; BURR-NEXT:    addq $64, %rcx
350; BURR-NEXT:    testq %r9, %r9
351; BURR-NEXT:    cmovneq %r8, %rcx
352; BURR-NEXT:    andq %rdx, %r10
353; BURR-NEXT:    bsrq %r10, %rdx
354; BURR-NEXT:    xorq $63, %rdx
355; BURR-NEXT:    andq %rsi, %r11
356; BURR-NEXT:    movl $127, %r8d
357; BURR-NEXT:    bsrq %r11, %rsi
358; BURR-NEXT:    cmoveq %r8, %rsi
359; BURR-NEXT:    xorq $63, %rsi
360; BURR-NEXT:    addq $64, %rsi
361; BURR-NEXT:    testq %r10, %r10
362; BURR-NEXT:    cmovneq %rdx, %rsi
363; BURR-NEXT:    subq $-128, %rsi
364; BURR-NEXT:    orq %r9, %rdi
365; BURR-NEXT:    cmovneq %rcx, %rsi
366; BURR-NEXT:    movq %rsi, (%rax)
367; BURR-NEXT:    movq $0, 24(%rax)
368; BURR-NEXT:    movq $0, 16(%rax)
369; BURR-NEXT:    movq $0, 8(%rax)
370; BURR-NEXT:    retq
371;
372; SRC-LABEL: test2:
373; SRC:       # %bb.0:
374; SRC-NEXT:    movq %rdi, %rax
375; SRC-NEXT:    xorl %edi, %edi
376; SRC-NEXT:    movq %rsi, %r11
377; SRC-NEXT:    negq %r11
378; SRC-NEXT:    movl $0, %r10d
379; SRC-NEXT:    sbbq %rdx, %r10
380; SRC-NEXT:    movl $0, %r9d
381; SRC-NEXT:    sbbq %rcx, %r9
382; SRC-NEXT:    sbbq %r8, %rdi
383; SRC-NEXT:    andq %rdx, %r10
384; SRC-NEXT:    andq %rcx, %r9
385; SRC-NEXT:    andq %r8, %rdi
386; SRC-NEXT:    andq %rsi, %r11
387; SRC-NEXT:    bsrq %rdi, %rcx
388; SRC-NEXT:    xorq $63, %rcx
389; SRC-NEXT:    bsrq %r9, %rdx
390; SRC-NEXT:    xorq $63, %rdx
391; SRC-NEXT:    addq $64, %rdx
392; SRC-NEXT:    testq %rdi, %rdi
393; SRC-NEXT:    cmovneq %rcx, %rdx
394; SRC-NEXT:    bsrq %r10, %rcx
395; SRC-NEXT:    xorq $63, %rcx
396; SRC-NEXT:    bsrq %r11, %r8
397; SRC-NEXT:    movl $127, %esi
398; SRC-NEXT:    cmovneq %r8, %rsi
399; SRC-NEXT:    xorq $63, %rsi
400; SRC-NEXT:    addq $64, %rsi
401; SRC-NEXT:    testq %r10, %r10
402; SRC-NEXT:    cmovneq %rcx, %rsi
403; SRC-NEXT:    subq $-128, %rsi
404; SRC-NEXT:    orq %r9, %rdi
405; SRC-NEXT:    cmovneq %rdx, %rsi
406; SRC-NEXT:    movq %rsi, (%rax)
407; SRC-NEXT:    movq $0, 24(%rax)
408; SRC-NEXT:    movq $0, 16(%rax)
409; SRC-NEXT:    movq $0, 8(%rax)
410; SRC-NEXT:    retq
411;
412; LIN-LABEL: test2:
413; LIN:       # %bb.0:
414; LIN-NEXT:    movq %rdi, %rax
415; LIN-NEXT:    movq %rsi, %rdi
416; LIN-NEXT:    negq %rdi
417; LIN-NEXT:    andq %rsi, %rdi
418; LIN-NEXT:    bsrq %rdi, %rsi
419; LIN-NEXT:    movl $127, %edi
420; LIN-NEXT:    cmovneq %rsi, %rdi
421; LIN-NEXT:    xorq $63, %rdi
422; LIN-NEXT:    addq $64, %rdi
423; LIN-NEXT:    xorl %r9d, %r9d
424; LIN-NEXT:    movl $0, %esi
425; LIN-NEXT:    sbbq %rdx, %rsi
426; LIN-NEXT:    andq %rdx, %rsi
427; LIN-NEXT:    bsrq %rsi, %rdx
428; LIN-NEXT:    xorq $63, %rdx
429; LIN-NEXT:    testq %rsi, %rsi
430; LIN-NEXT:    cmoveq %rdi, %rdx
431; LIN-NEXT:    subq $-128, %rdx
432; LIN-NEXT:    movl $0, %esi
433; LIN-NEXT:    sbbq %rcx, %rsi
434; LIN-NEXT:    andq %rcx, %rsi
435; LIN-NEXT:    bsrq %rsi, %rcx
436; LIN-NEXT:    xorq $63, %rcx
437; LIN-NEXT:    addq $64, %rcx
438; LIN-NEXT:    sbbq %r8, %r9
439; LIN-NEXT:    andq %r8, %r9
440; LIN-NEXT:    bsrq %r9, %rdi
441; LIN-NEXT:    xorq $63, %rdi
442; LIN-NEXT:    testq %r9, %r9
443; LIN-NEXT:    cmoveq %rcx, %rdi
444; LIN-NEXT:    orq %rsi, %r9
445; LIN-NEXT:    cmoveq %rdx, %rdi
446; LIN-NEXT:    movq %rdi, (%rax)
447; LIN-NEXT:    movq $0, 8(%rax)
448; LIN-NEXT:    movq $0, 16(%rax)
449; LIN-NEXT:    movq $0, 24(%rax)
450; LIN-NEXT:    retq
451  %b = sub i256 0, %a
452  %c = and i256 %b, %a
453  %d = call i256 @llvm.ctlz.i256(i256 %c, i1 false)
454  ret i256 %d
455}
456
457define i256 @test3(i256 %n) nounwind {
458; ILP-LABEL: test3:
459; ILP:       # %bb.0:
460; ILP-NEXT:    movq %rdi, %rax
461; ILP-NEXT:    xorl %r10d, %r10d
462; ILP-NEXT:    movq %rsi, %r9
463; ILP-NEXT:    negq %r9
464; ILP-NEXT:    movl $0, %r11d
465; ILP-NEXT:    sbbq %rdx, %r11
466; ILP-NEXT:    movl $0, %edi
467; ILP-NEXT:    sbbq %rcx, %rdi
468; ILP-NEXT:    sbbq %r8, %r10
469; ILP-NEXT:    notq %rcx
470; ILP-NEXT:    andq %rdi, %rcx
471; ILP-NEXT:    bsrq %rcx, %rdi
472; ILP-NEXT:    notq %rdx
473; ILP-NEXT:    andq %r11, %rdx
474; ILP-NEXT:    xorq $63, %rdi
475; ILP-NEXT:    notq %r8
476; ILP-NEXT:    andq %r10, %r8
477; ILP-NEXT:    bsrq %r8, %r10
478; ILP-NEXT:    xorq $63, %r10
479; ILP-NEXT:    addq $64, %rdi
480; ILP-NEXT:    bsrq %rdx, %r11
481; ILP-NEXT:    notq %rsi
482; ILP-NEXT:    testq %r8, %r8
483; ILP-NEXT:    movq $0, 24(%rax)
484; ILP-NEXT:    movq $0, 16(%rax)
485; ILP-NEXT:    movq $0, 8(%rax)
486; ILP-NEXT:    cmovneq %r10, %rdi
487; ILP-NEXT:    xorq $63, %r11
488; ILP-NEXT:    andq %r9, %rsi
489; ILP-NEXT:    movl $127, %r9d
490; ILP-NEXT:    bsrq %rsi, %rsi
491; ILP-NEXT:    cmoveq %r9, %rsi
492; ILP-NEXT:    xorq $63, %rsi
493; ILP-NEXT:    addq $64, %rsi
494; ILP-NEXT:    testq %rdx, %rdx
495; ILP-NEXT:    cmovneq %r11, %rsi
496; ILP-NEXT:    subq $-128, %rsi
497; ILP-NEXT:    orq %rcx, %r8
498; ILP-NEXT:    cmovneq %rdi, %rsi
499; ILP-NEXT:    movq %rsi, (%rax)
500; ILP-NEXT:    retq
501;
502; HYBRID-LABEL: test3:
503; HYBRID:       # %bb.0:
504; HYBRID-NEXT:    pushq %rbx
505; HYBRID-NEXT:    movq %rdi, %rax
506; HYBRID-NEXT:    xorl %edi, %edi
507; HYBRID-NEXT:    movq %rsi, %r9
508; HYBRID-NEXT:    negq %r9
509; HYBRID-NEXT:    movl $0, %r10d
510; HYBRID-NEXT:    sbbq %rdx, %r10
511; HYBRID-NEXT:    movl $0, %r11d
512; HYBRID-NEXT:    sbbq %rcx, %r11
513; HYBRID-NEXT:    sbbq %r8, %rdi
514; HYBRID-NEXT:    notq %r8
515; HYBRID-NEXT:    andq %rdi, %r8
516; HYBRID-NEXT:    bsrq %r8, %rbx
517; HYBRID-NEXT:    xorq $63, %rbx
518; HYBRID-NEXT:    notq %rcx
519; HYBRID-NEXT:    andq %r11, %rcx
520; HYBRID-NEXT:    bsrq %rcx, %rdi
521; HYBRID-NEXT:    xorq $63, %rdi
522; HYBRID-NEXT:    addq $64, %rdi
523; HYBRID-NEXT:    testq %r8, %r8
524; HYBRID-NEXT:    cmovneq %rbx, %rdi
525; HYBRID-NEXT:    notq %rdx
526; HYBRID-NEXT:    andq %r10, %rdx
527; HYBRID-NEXT:    bsrq %rdx, %rbx
528; HYBRID-NEXT:    xorq $63, %rbx
529; HYBRID-NEXT:    notq %rsi
530; HYBRID-NEXT:    andq %r9, %rsi
531; HYBRID-NEXT:    movl $127, %r9d
532; HYBRID-NEXT:    bsrq %rsi, %rsi
533; HYBRID-NEXT:    cmoveq %r9, %rsi
534; HYBRID-NEXT:    xorq $63, %rsi
535; HYBRID-NEXT:    addq $64, %rsi
536; HYBRID-NEXT:    testq %rdx, %rdx
537; HYBRID-NEXT:    cmovneq %rbx, %rsi
538; HYBRID-NEXT:    subq $-128, %rsi
539; HYBRID-NEXT:    orq %r8, %rcx
540; HYBRID-NEXT:    cmovneq %rdi, %rsi
541; HYBRID-NEXT:    movq %rsi, (%rax)
542; HYBRID-NEXT:    movq $0, 24(%rax)
543; HYBRID-NEXT:    movq $0, 16(%rax)
544; HYBRID-NEXT:    movq $0, 8(%rax)
545; HYBRID-NEXT:    popq %rbx
546; HYBRID-NEXT:    retq
547;
548; BURR-LABEL: test3:
549; BURR:       # %bb.0:
550; BURR-NEXT:    pushq %rbx
551; BURR-NEXT:    movq %rdi, %rax
552; BURR-NEXT:    xorl %edi, %edi
553; BURR-NEXT:    movq %rsi, %r9
554; BURR-NEXT:    negq %r9
555; BURR-NEXT:    movl $0, %r10d
556; BURR-NEXT:    sbbq %rdx, %r10
557; BURR-NEXT:    movl $0, %r11d
558; BURR-NEXT:    sbbq %rcx, %r11
559; BURR-NEXT:    sbbq %r8, %rdi
560; BURR-NEXT:    notq %r8
561; BURR-NEXT:    andq %rdi, %r8
562; BURR-NEXT:    bsrq %r8, %rbx
563; BURR-NEXT:    xorq $63, %rbx
564; BURR-NEXT:    notq %rcx
565; BURR-NEXT:    andq %r11, %rcx
566; BURR-NEXT:    bsrq %rcx, %rdi
567; BURR-NEXT:    xorq $63, %rdi
568; BURR-NEXT:    addq $64, %rdi
569; BURR-NEXT:    testq %r8, %r8
570; BURR-NEXT:    cmovneq %rbx, %rdi
571; BURR-NEXT:    notq %rdx
572; BURR-NEXT:    andq %r10, %rdx
573; BURR-NEXT:    bsrq %rdx, %rbx
574; BURR-NEXT:    xorq $63, %rbx
575; BURR-NEXT:    notq %rsi
576; BURR-NEXT:    andq %r9, %rsi
577; BURR-NEXT:    movl $127, %r9d
578; BURR-NEXT:    bsrq %rsi, %rsi
579; BURR-NEXT:    cmoveq %r9, %rsi
580; BURR-NEXT:    xorq $63, %rsi
581; BURR-NEXT:    addq $64, %rsi
582; BURR-NEXT:    testq %rdx, %rdx
583; BURR-NEXT:    cmovneq %rbx, %rsi
584; BURR-NEXT:    subq $-128, %rsi
585; BURR-NEXT:    orq %r8, %rcx
586; BURR-NEXT:    cmovneq %rdi, %rsi
587; BURR-NEXT:    movq %rsi, (%rax)
588; BURR-NEXT:    movq $0, 24(%rax)
589; BURR-NEXT:    movq $0, 16(%rax)
590; BURR-NEXT:    movq $0, 8(%rax)
591; BURR-NEXT:    popq %rbx
592; BURR-NEXT:    retq
593;
594; SRC-LABEL: test3:
595; SRC:       # %bb.0:
596; SRC-NEXT:    movq %rdi, %rax
597; SRC-NEXT:    movq %rsi, %r9
598; SRC-NEXT:    notq %r9
599; SRC-NEXT:    xorl %r10d, %r10d
600; SRC-NEXT:    negq %rsi
601; SRC-NEXT:    movl $0, %r11d
602; SRC-NEXT:    sbbq %rdx, %r11
603; SRC-NEXT:    notq %rdx
604; SRC-NEXT:    movl $0, %edi
605; SRC-NEXT:    sbbq %rcx, %rdi
606; SRC-NEXT:    notq %rcx
607; SRC-NEXT:    sbbq %r8, %r10
608; SRC-NEXT:    notq %r8
609; SRC-NEXT:    andq %r11, %rdx
610; SRC-NEXT:    andq %rdi, %rcx
611; SRC-NEXT:    andq %r10, %r8
612; SRC-NEXT:    andq %r9, %rsi
613; SRC-NEXT:    bsrq %r8, %r9
614; SRC-NEXT:    xorq $63, %r9
615; SRC-NEXT:    bsrq %rcx, %rdi
616; SRC-NEXT:    xorq $63, %rdi
617; SRC-NEXT:    addq $64, %rdi
618; SRC-NEXT:    testq %r8, %r8
619; SRC-NEXT:    cmovneq %r9, %rdi
620; SRC-NEXT:    bsrq %rdx, %r9
621; SRC-NEXT:    xorq $63, %r9
622; SRC-NEXT:    bsrq %rsi, %r10
623; SRC-NEXT:    movl $127, %esi
624; SRC-NEXT:    cmovneq %r10, %rsi
625; SRC-NEXT:    xorq $63, %rsi
626; SRC-NEXT:    addq $64, %rsi
627; SRC-NEXT:    testq %rdx, %rdx
628; SRC-NEXT:    cmovneq %r9, %rsi
629; SRC-NEXT:    subq $-128, %rsi
630; SRC-NEXT:    orq %rcx, %r8
631; SRC-NEXT:    cmovneq %rdi, %rsi
632; SRC-NEXT:    movq %rsi, (%rax)
633; SRC-NEXT:    movq $0, 24(%rax)
634; SRC-NEXT:    movq $0, 16(%rax)
635; SRC-NEXT:    movq $0, 8(%rax)
636; SRC-NEXT:    retq
637;
638; LIN-LABEL: test3:
639; LIN:       # %bb.0:
640; LIN-NEXT:    movq %rdi, %rax
641; LIN-NEXT:    movq %rsi, %rdi
642; LIN-NEXT:    negq %rdi
643; LIN-NEXT:    notq %rsi
644; LIN-NEXT:    andq %rdi, %rsi
645; LIN-NEXT:    bsrq %rsi, %rsi
646; LIN-NEXT:    movl $127, %edi
647; LIN-NEXT:    cmovneq %rsi, %rdi
648; LIN-NEXT:    xorq $63, %rdi
649; LIN-NEXT:    addq $64, %rdi
650; LIN-NEXT:    xorl %r9d, %r9d
651; LIN-NEXT:    movl $0, %esi
652; LIN-NEXT:    sbbq %rdx, %rsi
653; LIN-NEXT:    notq %rdx
654; LIN-NEXT:    andq %rsi, %rdx
655; LIN-NEXT:    bsrq %rdx, %rsi
656; LIN-NEXT:    xorq $63, %rsi
657; LIN-NEXT:    testq %rdx, %rdx
658; LIN-NEXT:    cmoveq %rdi, %rsi
659; LIN-NEXT:    subq $-128, %rsi
660; LIN-NEXT:    movl $0, %edx
661; LIN-NEXT:    sbbq %rcx, %rdx
662; LIN-NEXT:    notq %rcx
663; LIN-NEXT:    andq %rdx, %rcx
664; LIN-NEXT:    bsrq %rcx, %rdx
665; LIN-NEXT:    xorq $63, %rdx
666; LIN-NEXT:    addq $64, %rdx
667; LIN-NEXT:    sbbq %r8, %r9
668; LIN-NEXT:    notq %r8
669; LIN-NEXT:    andq %r9, %r8
670; LIN-NEXT:    bsrq %r8, %rdi
671; LIN-NEXT:    xorq $63, %rdi
672; LIN-NEXT:    testq %r8, %r8
673; LIN-NEXT:    cmoveq %rdx, %rdi
674; LIN-NEXT:    orq %rcx, %r8
675; LIN-NEXT:    cmoveq %rsi, %rdi
676; LIN-NEXT:    movq %rdi, (%rax)
677; LIN-NEXT:    movq $0, 8(%rax)
678; LIN-NEXT:    movq $0, 16(%rax)
679; LIN-NEXT:    movq $0, 24(%rax)
680; LIN-NEXT:    retq
681  %m = sub i256 -1, %n
682  %x = sub i256 0, %n
683  %y = and i256 %x, %m
684  %z = call i256 @llvm.ctlz.i256(i256 %y, i1 false)
685  ret i256 %z
686}
687
688declare i256 @llvm.ctlz.i256(i256, i1) nounwind readnone
689
690define i64 @test4(i64 %a, i64 %b) nounwind {
691; ILP-LABEL: test4:
692; ILP:       # %bb.0:
693; ILP-NEXT:    xorl %ecx, %ecx
694; ILP-NEXT:    xorl %edx, %edx
695; ILP-NEXT:    incq %rsi
696; ILP-NEXT:    sete %dl
697; ILP-NEXT:    movl $2, %eax
698; ILP-NEXT:    cmpq %rdi, %rsi
699; ILP-NEXT:    sbbq $0, %rdx
700; ILP-NEXT:    movl $0, %edx
701; ILP-NEXT:    sbbq %rdx, %rdx
702; ILP-NEXT:    sbbq %rcx, %rcx
703; ILP-NEXT:    adcq $-1, %rax
704; ILP-NEXT:    retq
705;
706; HYBRID-LABEL: test4:
707; HYBRID:       # %bb.0:
708; HYBRID-NEXT:    xorl %ecx, %ecx
709; HYBRID-NEXT:    xorl %edx, %edx
710; HYBRID-NEXT:    incq %rsi
711; HYBRID-NEXT:    sete %dl
712; HYBRID-NEXT:    movl $2, %eax
713; HYBRID-NEXT:    cmpq %rdi, %rsi
714; HYBRID-NEXT:    sbbq $0, %rdx
715; HYBRID-NEXT:    movl $0, %edx
716; HYBRID-NEXT:    sbbq %rdx, %rdx
717; HYBRID-NEXT:    sbbq %rcx, %rcx
718; HYBRID-NEXT:    adcq $-1, %rax
719; HYBRID-NEXT:    retq
720;
721; BURR-LABEL: test4:
722; BURR:       # %bb.0:
723; BURR-NEXT:    xorl %ecx, %ecx
724; BURR-NEXT:    xorl %edx, %edx
725; BURR-NEXT:    incq %rsi
726; BURR-NEXT:    sete %dl
727; BURR-NEXT:    movl $2, %eax
728; BURR-NEXT:    cmpq %rdi, %rsi
729; BURR-NEXT:    sbbq $0, %rdx
730; BURR-NEXT:    movl $0, %edx
731; BURR-NEXT:    sbbq %rdx, %rdx
732; BURR-NEXT:    sbbq %rcx, %rcx
733; BURR-NEXT:    adcq $-1, %rax
734; BURR-NEXT:    retq
735;
736; SRC-LABEL: test4:
737; SRC:       # %bb.0:
738; SRC-NEXT:    xorl %eax, %eax
739; SRC-NEXT:    incq %rsi
740; SRC-NEXT:    sete %al
741; SRC-NEXT:    xorl %ecx, %ecx
742; SRC-NEXT:    cmpq %rdi, %rsi
743; SRC-NEXT:    sbbq $0, %rax
744; SRC-NEXT:    movl $0, %eax
745; SRC-NEXT:    sbbq %rax, %rax
746; SRC-NEXT:    sbbq %rcx, %rcx
747; SRC-NEXT:    movl $2, %eax
748; SRC-NEXT:    adcq $-1, %rax
749; SRC-NEXT:    retq
750;
751; LIN-LABEL: test4:
752; LIN:       # %bb.0:
753; LIN-NEXT:    movl $2, %eax
754; LIN-NEXT:    xorl %ecx, %ecx
755; LIN-NEXT:    xorl %edx, %edx
756; LIN-NEXT:    incq %rsi
757; LIN-NEXT:    sete %dl
758; LIN-NEXT:    cmpq %rdi, %rsi
759; LIN-NEXT:    sbbq $0, %rdx
760; LIN-NEXT:    movl $0, %edx
761; LIN-NEXT:    sbbq %rdx, %rdx
762; LIN-NEXT:    sbbq %rcx, %rcx
763; LIN-NEXT:    adcq $-1, %rax
764; LIN-NEXT:    retq
765  %r = zext i64 %b to i256
766  %u = add i256 %r, 1
767  %w = and i256 %u, 1461501637330902918203684832716283019655932542975
768  %x = zext i64 %a to i256
769  %c = icmp uge i256 %w, %x
770  %y = select i1 %c, i64 0, i64 1
771  %z = add i64 %y, 1
772  ret i64 %z
773}
774
775define i256 @PR25498(i256 %a) nounwind {
776; ILP-LABEL: PR25498:
777; ILP:       # %bb.0:
778; ILP-NEXT:    pushq %rbx
779; ILP-NEXT:    movq %rdi, %rax
780; ILP-NEXT:    xorl %r9d, %r9d
781; ILP-NEXT:    movq %rsi, %rbx
782; ILP-NEXT:    negq %rbx
783; ILP-NEXT:    movl $0, %r11d
784; ILP-NEXT:    sbbq %rdx, %r11
785; ILP-NEXT:    movl $0, %r10d
786; ILP-NEXT:    sbbq %rcx, %r10
787; ILP-NEXT:    movl $0, %edi
788; ILP-NEXT:    sbbq %r8, %rdi
789; ILP-NEXT:    orq %r8, %rdx
790; ILP-NEXT:    orq %rcx, %rsi
791; ILP-NEXT:    orq %rdx, %rsi
792; ILP-NEXT:    je .LBB4_1
793; ILP-NEXT:  # %bb.2: # %cond.false
794; ILP-NEXT:    bsrq %r11, %rdx
795; ILP-NEXT:    bsrq %rdi, %rcx
796; ILP-NEXT:    xorq $63, %rcx
797; ILP-NEXT:    bsrq %r10, %rsi
798; ILP-NEXT:    xorq $63, %rsi
799; ILP-NEXT:    addq $64, %rsi
800; ILP-NEXT:    testq %rdi, %rdi
801; ILP-NEXT:    cmovneq %rcx, %rsi
802; ILP-NEXT:    xorq $63, %rdx
803; ILP-NEXT:    bsrq %rbx, %rcx
804; ILP-NEXT:    xorq $63, %rcx
805; ILP-NEXT:    addq $64, %rcx
806; ILP-NEXT:    testq %r11, %r11
807; ILP-NEXT:    cmovneq %rdx, %rcx
808; ILP-NEXT:    subq $-128, %rcx
809; ILP-NEXT:    xorl %r9d, %r9d
810; ILP-NEXT:    orq %rdi, %r10
811; ILP-NEXT:    cmovneq %rsi, %rcx
812; ILP-NEXT:    jmp .LBB4_3
813; ILP-NEXT:  .LBB4_1:
814; ILP-NEXT:    movl $256, %ecx # imm = 0x100
815; ILP-NEXT:  .LBB4_3: # %cond.end
816; ILP-NEXT:    movq %rcx, (%rax)
817; ILP-NEXT:    movq %r9, 8(%rax)
818; ILP-NEXT:    movq %r9, 16(%rax)
819; ILP-NEXT:    movq %r9, 24(%rax)
820; ILP-NEXT:    popq %rbx
821; ILP-NEXT:    retq
822;
823; HYBRID-LABEL: PR25498:
824; HYBRID:       # %bb.0:
825; HYBRID-NEXT:    pushq %rbx
826; HYBRID-NEXT:    movq %rdi, %rax
827; HYBRID-NEXT:    xorl %r9d, %r9d
828; HYBRID-NEXT:    movq %rsi, %rbx
829; HYBRID-NEXT:    negq %rbx
830; HYBRID-NEXT:    movl $0, %r11d
831; HYBRID-NEXT:    sbbq %rdx, %r11
832; HYBRID-NEXT:    movl $0, %r10d
833; HYBRID-NEXT:    sbbq %rcx, %r10
834; HYBRID-NEXT:    movl $0, %edi
835; HYBRID-NEXT:    sbbq %r8, %rdi
836; HYBRID-NEXT:    orq %r8, %rdx
837; HYBRID-NEXT:    orq %rcx, %rsi
838; HYBRID-NEXT:    orq %rdx, %rsi
839; HYBRID-NEXT:    je .LBB4_1
840; HYBRID-NEXT:  # %bb.2: # %cond.false
841; HYBRID-NEXT:    bsrq %rdi, %rcx
842; HYBRID-NEXT:    xorq $63, %rcx
843; HYBRID-NEXT:    bsrq %r10, %rdx
844; HYBRID-NEXT:    xorq $63, %rdx
845; HYBRID-NEXT:    addq $64, %rdx
846; HYBRID-NEXT:    testq %rdi, %rdi
847; HYBRID-NEXT:    cmovneq %rcx, %rdx
848; HYBRID-NEXT:    bsrq %r11, %rsi
849; HYBRID-NEXT:    xorq $63, %rsi
850; HYBRID-NEXT:    bsrq %rbx, %rcx
851; HYBRID-NEXT:    xorq $63, %rcx
852; HYBRID-NEXT:    addq $64, %rcx
853; HYBRID-NEXT:    testq %r11, %r11
854; HYBRID-NEXT:    cmovneq %rsi, %rcx
855; HYBRID-NEXT:    subq $-128, %rcx
856; HYBRID-NEXT:    orq %rdi, %r10
857; HYBRID-NEXT:    cmovneq %rdx, %rcx
858; HYBRID-NEXT:    xorl %r9d, %r9d
859; HYBRID-NEXT:    jmp .LBB4_3
860; HYBRID-NEXT:  .LBB4_1:
861; HYBRID-NEXT:    movl $256, %ecx # imm = 0x100
862; HYBRID-NEXT:  .LBB4_3: # %cond.end
863; HYBRID-NEXT:    movq %rcx, (%rax)
864; HYBRID-NEXT:    movq %r9, 8(%rax)
865; HYBRID-NEXT:    movq %r9, 16(%rax)
866; HYBRID-NEXT:    movq %r9, 24(%rax)
867; HYBRID-NEXT:    popq %rbx
868; HYBRID-NEXT:    retq
869;
870; BURR-LABEL: PR25498:
871; BURR:       # %bb.0:
872; BURR-NEXT:    pushq %rbx
873; BURR-NEXT:    movq %rdi, %rax
874; BURR-NEXT:    xorl %r9d, %r9d
875; BURR-NEXT:    movq %rsi, %rbx
876; BURR-NEXT:    negq %rbx
877; BURR-NEXT:    movl $0, %r11d
878; BURR-NEXT:    sbbq %rdx, %r11
879; BURR-NEXT:    movl $0, %r10d
880; BURR-NEXT:    sbbq %rcx, %r10
881; BURR-NEXT:    movl $0, %edi
882; BURR-NEXT:    sbbq %r8, %rdi
883; BURR-NEXT:    orq %r8, %rdx
884; BURR-NEXT:    orq %rcx, %rsi
885; BURR-NEXT:    orq %rdx, %rsi
886; BURR-NEXT:    je .LBB4_1
887; BURR-NEXT:  # %bb.2: # %cond.false
888; BURR-NEXT:    bsrq %rdi, %rcx
889; BURR-NEXT:    xorq $63, %rcx
890; BURR-NEXT:    bsrq %r10, %rdx
891; BURR-NEXT:    xorq $63, %rdx
892; BURR-NEXT:    addq $64, %rdx
893; BURR-NEXT:    testq %rdi, %rdi
894; BURR-NEXT:    cmovneq %rcx, %rdx
895; BURR-NEXT:    bsrq %r11, %rsi
896; BURR-NEXT:    xorq $63, %rsi
897; BURR-NEXT:    bsrq %rbx, %rcx
898; BURR-NEXT:    xorq $63, %rcx
899; BURR-NEXT:    addq $64, %rcx
900; BURR-NEXT:    testq %r11, %r11
901; BURR-NEXT:    cmovneq %rsi, %rcx
902; BURR-NEXT:    subq $-128, %rcx
903; BURR-NEXT:    orq %rdi, %r10
904; BURR-NEXT:    cmovneq %rdx, %rcx
905; BURR-NEXT:    xorl %r9d, %r9d
906; BURR-NEXT:    jmp .LBB4_3
907; BURR-NEXT:  .LBB4_1:
908; BURR-NEXT:    movl $256, %ecx # imm = 0x100
909; BURR-NEXT:  .LBB4_3: # %cond.end
910; BURR-NEXT:    movq %rcx, (%rax)
911; BURR-NEXT:    movq %r9, 8(%rax)
912; BURR-NEXT:    movq %r9, 16(%rax)
913; BURR-NEXT:    movq %r9, 24(%rax)
914; BURR-NEXT:    popq %rbx
915; BURR-NEXT:    retq
916;
917; SRC-LABEL: PR25498:
918; SRC:       # %bb.0:
919; SRC-NEXT:    pushq %rbx
920; SRC-NEXT:    movq %rdi, %rax
921; SRC-NEXT:    xorl %r9d, %r9d
922; SRC-NEXT:    movq %rsi, %rbx
923; SRC-NEXT:    negq %rbx
924; SRC-NEXT:    movl $0, %r11d
925; SRC-NEXT:    sbbq %rdx, %r11
926; SRC-NEXT:    movl $0, %r10d
927; SRC-NEXT:    sbbq %rcx, %r10
928; SRC-NEXT:    movl $0, %edi
929; SRC-NEXT:    sbbq %r8, %rdi
930; SRC-NEXT:    orq %r8, %rdx
931; SRC-NEXT:    orq %rcx, %rsi
932; SRC-NEXT:    orq %rdx, %rsi
933; SRC-NEXT:    je .LBB4_1
934; SRC-NEXT:  # %bb.2: # %cond.false
935; SRC-NEXT:    bsrq %rdi, %rcx
936; SRC-NEXT:    xorq $63, %rcx
937; SRC-NEXT:    bsrq %r10, %rdx
938; SRC-NEXT:    xorq $63, %rdx
939; SRC-NEXT:    addq $64, %rdx
940; SRC-NEXT:    testq %rdi, %rdi
941; SRC-NEXT:    cmovneq %rcx, %rdx
942; SRC-NEXT:    bsrq %r11, %rsi
943; SRC-NEXT:    xorq $63, %rsi
944; SRC-NEXT:    bsrq %rbx, %rcx
945; SRC-NEXT:    xorq $63, %rcx
946; SRC-NEXT:    addq $64, %rcx
947; SRC-NEXT:    testq %r11, %r11
948; SRC-NEXT:    cmovneq %rsi, %rcx
949; SRC-NEXT:    subq $-128, %rcx
950; SRC-NEXT:    orq %rdi, %r10
951; SRC-NEXT:    cmovneq %rdx, %rcx
952; SRC-NEXT:    xorl %r9d, %r9d
953; SRC-NEXT:    jmp .LBB4_3
954; SRC-NEXT:  .LBB4_1:
955; SRC-NEXT:    movl $256, %ecx # imm = 0x100
956; SRC-NEXT:  .LBB4_3: # %cond.end
957; SRC-NEXT:    movq %rcx, (%rax)
958; SRC-NEXT:    movq %r9, 8(%rax)
959; SRC-NEXT:    movq %r9, 16(%rax)
960; SRC-NEXT:    movq %r9, 24(%rax)
961; SRC-NEXT:    popq %rbx
962; SRC-NEXT:    retq
963;
964; LIN-LABEL: PR25498:
965; LIN:       # %bb.0:
966; LIN-NEXT:    pushq %rbx
967; LIN-NEXT:    movq %rdi, %rax
968; LIN-NEXT:    movq %rsi, %rbx
969; LIN-NEXT:    negq %rbx
970; LIN-NEXT:    xorl %r9d, %r9d
971; LIN-NEXT:    movl $0, %edi
972; LIN-NEXT:    sbbq %rdx, %rdi
973; LIN-NEXT:    movl $0, %r10d
974; LIN-NEXT:    sbbq %rcx, %r10
975; LIN-NEXT:    movl $0, %r11d
976; LIN-NEXT:    sbbq %r8, %r11
977; LIN-NEXT:    orq %rcx, %rsi
978; LIN-NEXT:    orq %r8, %rdx
979; LIN-NEXT:    orq %rsi, %rdx
980; LIN-NEXT:    je .LBB4_1
981; LIN-NEXT:  # %bb.2: # %cond.false
982; LIN-NEXT:    bsrq %rbx, %rcx
983; LIN-NEXT:    xorq $63, %rcx
984; LIN-NEXT:    addq $64, %rcx
985; LIN-NEXT:    bsrq %rdi, %rdx
986; LIN-NEXT:    xorq $63, %rdx
987; LIN-NEXT:    testq %rdi, %rdi
988; LIN-NEXT:    cmoveq %rcx, %rdx
989; LIN-NEXT:    subq $-128, %rdx
990; LIN-NEXT:    bsrq %r10, %rsi
991; LIN-NEXT:    xorq $63, %rsi
992; LIN-NEXT:    addq $64, %rsi
993; LIN-NEXT:    bsrq %r11, %rcx
994; LIN-NEXT:    xorq $63, %rcx
995; LIN-NEXT:    testq %r11, %r11
996; LIN-NEXT:    cmoveq %rsi, %rcx
997; LIN-NEXT:    orq %r11, %r10
998; LIN-NEXT:    cmoveq %rdx, %rcx
999; LIN-NEXT:    xorl %r9d, %r9d
1000; LIN-NEXT:    jmp .LBB4_3
1001; LIN-NEXT:  .LBB4_1:
1002; LIN-NEXT:    movl $256, %ecx # imm = 0x100
1003; LIN-NEXT:  .LBB4_3: # %cond.end
1004; LIN-NEXT:    movq %rcx, (%rax)
1005; LIN-NEXT:    movq %r9, 8(%rax)
1006; LIN-NEXT:    movq %r9, 16(%rax)
1007; LIN-NEXT:    movq %r9, 24(%rax)
1008; LIN-NEXT:    popq %rbx
1009; LIN-NEXT:    retq
1010  %b = sub i256 0, %a
1011  %cmpz = icmp eq i256 %b, 0
1012  br i1 %cmpz, label %cond.end, label %cond.false
1013
1014cond.false:
1015  %d = call i256 @llvm.ctlz.i256(i256 %b, i1 true)
1016  br label %cond.end
1017
1018cond.end:
1019  %ctz = phi i256 [ 256, %0 ], [ %d, %cond.false ]
1020  ret i256 %ctz
1021}
1022
1023