1 ; RUN: llc -mtriple=i686-linux-gnu %s -o - | FileCheck %s 2 3 4 define i32 @branch_eq(i64 %a, i64 %b) { 5 entry: 6 %cmp = icmp eq i64 %a, %b 7 br i1 %cmp, label %bb1, label %bb2 8 bb1: 9 ret i32 1 10 bb2: 11 ret i32 2 12 13 ; CHECK-LABEL: branch_eq: 14 ; CHECK: movl 4(%esp), [[LHSLo:%[a-z]+]] 15 ; CHECK: movl 8(%esp), [[LHSHi:%[a-z]+]] 16 ; CHECK: xorl 16(%esp), [[LHSHi]] 17 ; CHECK: xorl 12(%esp), [[LHSLo]] 18 ; CHECK: orl [[LHSHi]], [[LHSLo]] 19 ; CHECK: jne [[FALSE:.LBB[0-9_]+]] 20 ; CHECK: movl $1, %eax 21 ; CHECK: retl 22 ; CHECK: [[FALSE]]: 23 ; CHECK: movl $2, %eax 24 ; CHECK: retl 25 } 26 27 define i32 @branch_slt(i64 %a, i64 %b) { 28 entry: 29 %cmp = icmp slt i64 %a, %b 30 br i1 %cmp, label %bb1, label %bb2 31 bb1: 32 ret i32 1 33 bb2: 34 ret i32 2 35 36 ; CHECK-LABEL: branch_slt: 37 ; CHECK: movl 4(%esp), [[LHSLo:%[a-z]+]] 38 ; CHECK: movl 8(%esp), [[LHSHi:%[a-z]+]] 39 ; CHECK: cmpl 12(%esp), [[LHSLo]] 40 ; CHECK: sbbl 16(%esp), [[LHSHi]] 41 ; CHECK: jge [[FALSE:.LBB[0-9_]+]] 42 ; CHECK: movl $1, %eax 43 ; CHECK: retl 44 ; CHECK: [[FALSE]]: 45 ; CHECK: movl $2, %eax 46 ; CHECK: retl 47 } 48 49 define i32 @branch_ule(i64 %a, i64 %b) { 50 entry: 51 %cmp = icmp ule i64 %a, %b 52 br i1 %cmp, label %bb1, label %bb2 53 bb1: 54 ret i32 1 55 bb2: 56 ret i32 2 57 58 ; CHECK-LABEL: branch_ule: 59 ; CHECK: movl 12(%esp), [[RHSLo:%[a-z]+]] 60 ; CHECK: movl 16(%esp), [[RHSHi:%[a-z]+]] 61 ; CHECK: cmpl 4(%esp), [[RHSLo]] 62 ; CHECK: sbbl 8(%esp), [[RHSHi]] 63 ; CHECK: jb [[FALSE:.LBB[0-9_]+]] 64 ; CHECK: movl $1, %eax 65 ; CHECK: retl 66 ; CHECK: [[FALSE]]: 67 ; CHECK: movl $2, %eax 68 ; CHECK: retl 69 } 70 71 define i32 @set_gt(i64 %a, i64 %b) { 72 entry: 73 %cmp = icmp sgt i64 %a, %b 74 %res = select i1 %cmp, i32 1, i32 0 75 ret i32 %res 76 77 ; CHECK-LABEL: set_gt: 78 ; CHECK: movl 12(%esp), [[RHSLo:%[a-z]+]] 79 ; CHECK: movl 16(%esp), [[RHSHi:%[a-z]+]] 80 ; CHECK: cmpl 4(%esp), [[RHSLo]] 81 ; CHECK: sbbl 8(%esp), [[RHSHi]] 82 ; CHECK: setl %al 83 ; CHECK: retl 84 } 85 86 define i32 @test_wide(i128 %a, i128 %b) { 87 entry: 88 %cmp = icmp slt i128 %a, %b 89 br i1 %cmp, label %bb1, label %bb2 90 bb1: 91 ret i32 1 92 bb2: 93 ret i32 2 94 95 ; CHECK-LABEL: test_wide: 96 ; CHECK: cmpl 24(%esp) 97 ; CHECK: sbbl 28(%esp) 98 ; CHECK: sbbl 32(%esp) 99 ; CHECK: sbbl 36(%esp) 100 ; CHECK: jge [[FALSE:.LBB[0-9_]+]] 101 ; CHECK: movl $1, %eax 102 ; CHECK: retl 103 ; CHECK: [[FALSE]]: 104 ; CHECK: movl $2, %eax 105 ; CHECK: retl 106 } 107 108 define i32 @test_carry_false(i64 %a, i64 %b) { 109 entry: 110 %x = and i64 %a, -4294967296 ;0xffffffff00000000 111 %y = and i64 %b, -4294967296 112 %cmp = icmp slt i64 %x, %y 113 br i1 %cmp, label %bb1, label %bb2 114 bb1: 115 ret i32 1 116 bb2: 117 ret i32 2 118 119 ; The comparison of the low bits will be folded to a CARRY_FALSE node. Make 120 ; sure the code can handle that. 121 ; CHECK-LABEL: carry_false: 122 ; CHECK: movl 8(%esp), [[LHSHi:%[a-z]+]] 123 ; CHECK: cmpl 16(%esp), [[LHSHi]] 124 ; CHECK: jge [[FALSE:.LBB[0-9_]+]] 125 ; CHECK: movl $1, %eax 126 ; CHECK: retl 127 ; CHECK: [[FALSE]]: 128 ; CHECK: movl $2, %eax 129 ; CHECK: retl 130 } 131