1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=i686-unknown-linux-gnu | FileCheck %s --check-prefix=X86
3; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s --check-prefix=X64
4
5define i32 @fn(i32 %a0, i32 %a1) {
6; X86-LABEL: fn:
7; X86:       # %bb.0: # %entry
8; X86-NEXT:    pushl %ebx
9; X86-NEXT:    .cfi_def_cfa_offset 8
10; X86-NEXT:    .cfi_offset %ebx, -8
11; X86-NEXT:    xorl %eax, %eax
12; X86-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
13; X86-NEXT:    sete %cl
14; X86-NEXT:    setne %al
15; X86-NEXT:    cmpl $1, {{[0-9]+}}(%esp)
16; X86-NEXT:    sete %dl
17; X86-NEXT:    negl %eax
18; X86-NEXT:    addb %cl, %cl
19; X86-NEXT:    movl %eax, %ebx
20; X86-NEXT:    shll %cl, %ebx
21; X86-NEXT:    addb %dl, %dl
22; X86-NEXT:    movl %edx, %ecx
23; X86-NEXT:    shll %cl, %eax
24; X86-NEXT:    .p2align 4, 0x90
25; X86-NEXT:  .LBB0_1: # %bb1
26; X86-NEXT:    # =>This Inner Loop Header: Depth=1
27; X86-NEXT:    testl %ebx, %ebx
28; X86-NEXT:    je .LBB0_1
29; X86-NEXT:  # %bb.2: # %bb2
30; X86-NEXT:    popl %ebx
31; X86-NEXT:    .cfi_def_cfa_offset 4
32; X86-NEXT:    retl
33;
34; X64-LABEL: fn:
35; X64:       # %bb.0: # %entry
36; X64-NEXT:    xorl %eax, %eax
37; X64-NEXT:    cmpl $1, %edi
38; X64-NEXT:    sete %cl
39; X64-NEXT:    setne %al
40; X64-NEXT:    cmpl $1, %esi
41; X64-NEXT:    sete %dl
42; X64-NEXT:    negl %eax
43; X64-NEXT:    addb %cl, %cl
44; X64-NEXT:    movl %eax, %esi
45; X64-NEXT:    shll %cl, %esi
46; X64-NEXT:    addb %dl, %dl
47; X64-NEXT:    movl %edx, %ecx
48; X64-NEXT:    shll %cl, %eax
49; X64-NEXT:    .p2align 4, 0x90
50; X64-NEXT:  .LBB0_1: # %bb1
51; X64-NEXT:    # =>This Inner Loop Header: Depth=1
52; X64-NEXT:    testl %esi, %esi
53; X64-NEXT:    je .LBB0_1
54; X64-NEXT:  # %bb.2: # %bb2
55; X64-NEXT:    retq
56entry:
57  %cmp1 = icmp ne i32 %a0, 1
58  %cmp2 = icmp eq i32 %a1, 1
59  %sel1 = select i1 %cmp1, i32 0, i32 2
60  %sel2 = select i1 %cmp2, i32 2, i32 0
61  %sext = sext i1 %cmp1 to i32
62  %shl1 = shl i32 %sext, %sel1
63  %shl2 = shl i32 %sext, %sel2
64  %tobool = icmp eq i32 %shl1, 0
65  br label %bb1
66
67bb1:                                              ; preds = %bb1, %entry
68  br i1 %tobool, label %bb1, label %bb2
69
70bb2:                                              ; preds = %bb1
71  ret i32 %shl2
72}
73