Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-apple-darwin | FileCheck %s -check-prefix=X64
      3 ; RUN: llc < %s -mtriple=i686-apple-darwin   | FileCheck %s -check-prefix=X32
      4 
      5 ; rdar://7329206
      6 
      7 ; In 32-bit the partial register stall would degrade performance.
      8 
      9 define zeroext i16 @test1(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
     10 ; X64-LABEL: test1:
     11 ; X64:       ## %bb.0: ## %entry
     12 ; X64-NEXT:    movl %esi, %eax
     13 ; X64-NEXT:    incl %eax
     14 ; X64-NEXT:    cmpw %di, %si
     15 ; X64-NEXT:    jne LBB0_2
     16 ; X64-NEXT:  ## %bb.1: ## %bb
     17 ; X64-NEXT:    pushq %rbx
     18 ; X64-NEXT:    movzwl %ax, %ebx
     19 ; X64-NEXT:    movl %ebx, %edi
     20 ; X64-NEXT:    callq _foo
     21 ; X64-NEXT:    movl %ebx, %eax
     22 ; X64-NEXT:    popq %rbx
     23 ; X64-NEXT:    retq
     24 ; X64-NEXT:  LBB0_2: ## %bb1
     25 ; X64-NEXT:    movzwl %ax, %eax
     26 ; X64-NEXT:    retq
     27 ;
     28 ; X32-LABEL: test1:
     29 ; X32:       ## %bb.0: ## %entry
     30 ; X32-NEXT:    pushl %esi
     31 ; X32-NEXT:    subl $8, %esp
     32 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
     33 ; X32-NEXT:    movl %ecx, %eax
     34 ; X32-NEXT:    incl %eax
     35 ; X32-NEXT:    cmpw {{[0-9]+}}(%esp), %cx
     36 ; X32-NEXT:    jne LBB0_2
     37 ; X32-NEXT:  ## %bb.1: ## %bb
     38 ; X32-NEXT:    movzwl %ax, %esi
     39 ; X32-NEXT:    movl %esi, (%esp)
     40 ; X32-NEXT:    calll _foo
     41 ; X32-NEXT:    movl %esi, %eax
     42 ; X32-NEXT:    jmp LBB0_3
     43 ; X32-NEXT:  LBB0_2: ## %bb1
     44 ; X32-NEXT:    movzwl %ax, %eax
     45 ; X32-NEXT:  LBB0_3: ## %bb1
     46 ; X32-NEXT:    addl $8, %esp
     47 ; X32-NEXT:    popl %esi
     48 ; X32-NEXT:    retl
     49 entry:
     50   %0 = icmp eq i16 %k, %c
     51   %1 = add i16 %k, 1
     52   br i1 %0, label %bb, label %bb1
     53 
     54 bb:
     55   tail call void @foo(i16 zeroext %1) nounwind
     56   ret i16 %1
     57 
     58 bb1:
     59   ret i16 %1
     60 }
     61 
     62 define zeroext i16 @test2(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
     63 ; X64-LABEL: test2:
     64 ; X64:       ## %bb.0: ## %entry
     65 ; X64-NEXT:    movl %esi, %eax
     66 ; X64-NEXT:    decl %eax
     67 ; X64-NEXT:    cmpw %di, %si
     68 ; X64-NEXT:    jne LBB1_2
     69 ; X64-NEXT:  ## %bb.1: ## %bb
     70 ; X64-NEXT:    pushq %rbx
     71 ; X64-NEXT:    movzwl %ax, %ebx
     72 ; X64-NEXT:    movl %ebx, %edi
     73 ; X64-NEXT:    callq _foo
     74 ; X64-NEXT:    movl %ebx, %eax
     75 ; X64-NEXT:    popq %rbx
     76 ; X64-NEXT:    retq
     77 ; X64-NEXT:  LBB1_2: ## %bb1
     78 ; X64-NEXT:    movzwl %ax, %eax
     79 ; X64-NEXT:    retq
     80 ;
     81 ; X32-LABEL: test2:
     82 ; X32:       ## %bb.0: ## %entry
     83 ; X32-NEXT:    pushl %esi
     84 ; X32-NEXT:    subl $8, %esp
     85 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
     86 ; X32-NEXT:    movl %ecx, %eax
     87 ; X32-NEXT:    decl %eax
     88 ; X32-NEXT:    cmpw {{[0-9]+}}(%esp), %cx
     89 ; X32-NEXT:    jne LBB1_2
     90 ; X32-NEXT:  ## %bb.1: ## %bb
     91 ; X32-NEXT:    movzwl %ax, %esi
     92 ; X32-NEXT:    movl %esi, (%esp)
     93 ; X32-NEXT:    calll _foo
     94 ; X32-NEXT:    movl %esi, %eax
     95 ; X32-NEXT:    jmp LBB1_3
     96 ; X32-NEXT:  LBB1_2: ## %bb1
     97 ; X32-NEXT:    movzwl %ax, %eax
     98 ; X32-NEXT:  LBB1_3: ## %bb1
     99 ; X32-NEXT:    addl $8, %esp
    100 ; X32-NEXT:    popl %esi
    101 ; X32-NEXT:    retl
    102 entry:
    103   %0 = icmp eq i16 %k, %c
    104   %1 = add i16 %k, -1
    105   br i1 %0, label %bb, label %bb1
    106 
    107 bb:
    108   tail call void @foo(i16 zeroext %1) nounwind
    109   ret i16 %1
    110 
    111 bb1:
    112   ret i16 %1
    113 }
    114 
    115 declare void @foo(i16 zeroext)
    116 
    117 define zeroext i16 @test3(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
    118 ; X64-LABEL: test3:
    119 ; X64:       ## %bb.0: ## %entry
    120 ; X64-NEXT:    movl %esi, %eax
    121 ; X64-NEXT:    addl $2, %eax
    122 ; X64-NEXT:    cmpw %di, %si
    123 ; X64-NEXT:    jne LBB2_2
    124 ; X64-NEXT:  ## %bb.1: ## %bb
    125 ; X64-NEXT:    pushq %rbx
    126 ; X64-NEXT:    movzwl %ax, %ebx
    127 ; X64-NEXT:    movl %ebx, %edi
    128 ; X64-NEXT:    callq _foo
    129 ; X64-NEXT:    movl %ebx, %eax
    130 ; X64-NEXT:    popq %rbx
    131 ; X64-NEXT:    retq
    132 ; X64-NEXT:  LBB2_2: ## %bb1
    133 ; X64-NEXT:    movzwl %ax, %eax
    134 ; X64-NEXT:    retq
    135 ;
    136 ; X32-LABEL: test3:
    137 ; X32:       ## %bb.0: ## %entry
    138 ; X32-NEXT:    pushl %esi
    139 ; X32-NEXT:    subl $8, %esp
    140 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    141 ; X32-NEXT:    movl %ecx, %eax
    142 ; X32-NEXT:    addl $2, %eax
    143 ; X32-NEXT:    cmpw {{[0-9]+}}(%esp), %cx
    144 ; X32-NEXT:    jne LBB2_2
    145 ; X32-NEXT:  ## %bb.1: ## %bb
    146 ; X32-NEXT:    movzwl %ax, %esi
    147 ; X32-NEXT:    movl %esi, (%esp)
    148 ; X32-NEXT:    calll _foo
    149 ; X32-NEXT:    movl %esi, %eax
    150 ; X32-NEXT:    jmp LBB2_3
    151 ; X32-NEXT:  LBB2_2: ## %bb1
    152 ; X32-NEXT:    movzwl %ax, %eax
    153 ; X32-NEXT:  LBB2_3: ## %bb1
    154 ; X32-NEXT:    addl $8, %esp
    155 ; X32-NEXT:    popl %esi
    156 ; X32-NEXT:    retl
    157 entry:
    158   %0 = add i16 %k, 2
    159   %1 = icmp eq i16 %k, %c
    160   br i1 %1, label %bb, label %bb1
    161 
    162 bb:
    163   tail call void @foo(i16 zeroext %0) nounwind
    164   ret i16 %0
    165 
    166 bb1:
    167   ret i16 %0
    168 }
    169 
    170 define zeroext i16 @test4(i16 zeroext %c, i16 zeroext %k) nounwind ssp {
    171 ; X64-LABEL: test4:
    172 ; X64:       ## %bb.0: ## %entry
    173 ; X64-NEXT:    movl %esi, %eax
    174 ; X64-NEXT:    addl %edi, %eax
    175 ; X64-NEXT:    cmpw %di, %si
    176 ; X64-NEXT:    jne LBB3_2
    177 ; X64-NEXT:  ## %bb.1: ## %bb
    178 ; X64-NEXT:    pushq %rbx
    179 ; X64-NEXT:    movzwl %ax, %ebx
    180 ; X64-NEXT:    movl %ebx, %edi
    181 ; X64-NEXT:    callq _foo
    182 ; X64-NEXT:    movl %ebx, %eax
    183 ; X64-NEXT:    popq %rbx
    184 ; X64-NEXT:    retq
    185 ; X64-NEXT:  LBB3_2: ## %bb1
    186 ; X64-NEXT:    movzwl %ax, %eax
    187 ; X64-NEXT:    retq
    188 ;
    189 ; X32-LABEL: test4:
    190 ; X32:       ## %bb.0: ## %entry
    191 ; X32-NEXT:    pushl %esi
    192 ; X32-NEXT:    subl $8, %esp
    193 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %ecx
    194 ; X32-NEXT:    movl {{[0-9]+}}(%esp), %edx
    195 ; X32-NEXT:    movl %edx, %eax
    196 ; X32-NEXT:    addl %ecx, %eax
    197 ; X32-NEXT:    cmpw %cx, %dx
    198 ; X32-NEXT:    jne LBB3_2
    199 ; X32-NEXT:  ## %bb.1: ## %bb
    200 ; X32-NEXT:    movzwl %ax, %esi
    201 ; X32-NEXT:    movl %esi, (%esp)
    202 ; X32-NEXT:    calll _foo
    203 ; X32-NEXT:    movl %esi, %eax
    204 ; X32-NEXT:    jmp LBB3_3
    205 ; X32-NEXT:  LBB3_2: ## %bb1
    206 ; X32-NEXT:    movzwl %ax, %eax
    207 ; X32-NEXT:  LBB3_3: ## %bb1
    208 ; X32-NEXT:    addl $8, %esp
    209 ; X32-NEXT:    popl %esi
    210 ; X32-NEXT:    retl
    211 entry:
    212   %0 = add i16 %k, %c
    213   %1 = icmp eq i16 %k, %c
    214   br i1 %1, label %bb, label %bb1
    215 
    216 bb:
    217   tail call void @foo(i16 zeroext %0) nounwind
    218   ret i16 %0
    219 
    220 bb1:
    221   ret i16 %0
    222 }
    223 
    224