Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -O0 -mtriple=x86_64-unknown-unknown -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefixes=X64,X64-CMOV
      3 ; RUN: llc < %s -O0 -mtriple=i686-unknown-unknown -mcpu=corei7 -verify-machineinstrs | FileCheck %s -check-prefixes=X86,X86-CMOV
      4 ; RUN: llc < %s -O0 -mtriple=i686-unknown-unknown -mcpu=corei7 -mattr=-cmov -verify-machineinstrs | FileCheck %s --check-prefixes=X86,X86-NOCMOV
      5 
      6 @sc32 = external global i32
      7 
      8 define void @atomic_fetch_add32() nounwind {
      9 ; X64-LABEL: atomic_fetch_add32:
     10 ; X64:       # %bb.0: # %entry
     11 ; X64-NEXT:    lock incl {{.*}}(%rip)
     12 ; X64-NEXT:    lock addl $3, {{.*}}(%rip)
     13 ; X64-NEXT:    movl $5, %eax
     14 ; X64-NEXT:    lock xaddl %eax, {{.*}}(%rip)
     15 ; X64-NEXT:    lock addl %eax, {{.*}}(%rip)
     16 ; X64-NEXT:    retq
     17 ;
     18 ; X86-LABEL: atomic_fetch_add32:
     19 ; X86:       # %bb.0: # %entry
     20 ; X86-NEXT:    lock incl sc32
     21 ; X86-NEXT:    lock addl $3, sc32
     22 ; X86-NEXT:    movl $5, %eax
     23 ; X86-NEXT:    lock xaddl %eax, sc32
     24 ; X86-NEXT:    lock addl %eax, sc32
     25 ; X86-NEXT:    retl
     26 entry:
     27   %t1 = atomicrmw add  i32* @sc32, i32 1 acquire
     28   %t2 = atomicrmw add  i32* @sc32, i32 3 acquire
     29   %t3 = atomicrmw add  i32* @sc32, i32 5 acquire
     30   %t4 = atomicrmw add  i32* @sc32, i32 %t3 acquire
     31   ret void
     32 }
     33 
     34 define void @atomic_fetch_sub32() nounwind {
     35 ; X64-LABEL: atomic_fetch_sub32:
     36 ; X64:       # %bb.0:
     37 ; X64-NEXT:    lock decl {{.*}}(%rip)
     38 ; X64-NEXT:    lock subl $3, {{.*}}(%rip)
     39 ; X64-NEXT:    movl $-5, %eax
     40 ; X64-NEXT:    lock xaddl %eax, {{.*}}(%rip)
     41 ; X64-NEXT:    lock subl %eax, {{.*}}(%rip)
     42 ; X64-NEXT:    retq
     43 ;
     44 ; X86-LABEL: atomic_fetch_sub32:
     45 ; X86:       # %bb.0:
     46 ; X86-NEXT:    lock decl sc32
     47 ; X86-NEXT:    lock subl $3, sc32
     48 ; X86-NEXT:    movl $-5, %eax
     49 ; X86-NEXT:    lock xaddl %eax, sc32
     50 ; X86-NEXT:    lock subl %eax, sc32
     51 ; X86-NEXT:    retl
     52   %t1 = atomicrmw sub  i32* @sc32, i32 1 acquire
     53   %t2 = atomicrmw sub  i32* @sc32, i32 3 acquire
     54   %t3 = atomicrmw sub  i32* @sc32, i32 5 acquire
     55   %t4 = atomicrmw sub  i32* @sc32, i32 %t3 acquire
     56   ret void
     57 }
     58 
     59 define void @atomic_fetch_and32() nounwind {
     60 ; X64-LABEL: atomic_fetch_and32:
     61 ; X64:       # %bb.0:
     62 ; X64-NEXT:    lock andl $3, {{.*}}(%rip)
     63 ; X64-NEXT:    movl sc32, %eax
     64 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
     65 ; X64-NEXT:  .LBB2_1: # %atomicrmw.start
     66 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
     67 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
     68 ; X64-NEXT:    movl %eax, %ecx
     69 ; X64-NEXT:    andl $5, %ecx
     70 ; X64-NEXT:    lock cmpxchgl %ecx, {{.*}}(%rip)
     71 ; X64-NEXT:    sete %dl
     72 ; X64-NEXT:    testb $1, %dl
     73 ; X64-NEXT:    movl %eax, %ecx
     74 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
     75 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
     76 ; X64-NEXT:    jne .LBB2_2
     77 ; X64-NEXT:    jmp .LBB2_1
     78 ; X64-NEXT:  .LBB2_2: # %atomicrmw.end
     79 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
     80 ; X64-NEXT:    lock andl %eax, {{.*}}(%rip)
     81 ; X64-NEXT:    retq
     82 ;
     83 ; X86-LABEL: atomic_fetch_and32:
     84 ; X86:       # %bb.0:
     85 ; X86-NEXT:    subl $8, %esp
     86 ; X86-NEXT:    lock andl $3, sc32
     87 ; X86-NEXT:    movl sc32, %eax
     88 ; X86-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
     89 ; X86-NEXT:  .LBB2_1: # %atomicrmw.start
     90 ; X86-NEXT:    # =>This Inner Loop Header: Depth=1
     91 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
     92 ; X86-NEXT:    movl %eax, %ecx
     93 ; X86-NEXT:    andl $5, %ecx
     94 ; X86-NEXT:    lock cmpxchgl %ecx, sc32
     95 ; X86-NEXT:    sete %dl
     96 ; X86-NEXT:    testb $1, %dl
     97 ; X86-NEXT:    movl %eax, %ecx
     98 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
     99 ; X86-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    100 ; X86-NEXT:    jne .LBB2_2
    101 ; X86-NEXT:    jmp .LBB2_1
    102 ; X86-NEXT:  .LBB2_2: # %atomicrmw.end
    103 ; X86-NEXT:    movl (%esp), %eax # 4-byte Reload
    104 ; X86-NEXT:    lock andl %eax, sc32
    105 ; X86-NEXT:    addl $8, %esp
    106 ; X86-NEXT:    retl
    107   %t1 = atomicrmw and  i32* @sc32, i32 3 acquire
    108   %t2 = atomicrmw and  i32* @sc32, i32 5 acquire
    109   %t3 = atomicrmw and  i32* @sc32, i32 %t2 acquire
    110   ret void
    111 }
    112 
    113 define void @atomic_fetch_or32() nounwind {
    114 ; X64-LABEL: atomic_fetch_or32:
    115 ; X64:       # %bb.0:
    116 ; X64-NEXT:    lock orl $3, {{.*}}(%rip)
    117 ; X64-NEXT:    movl sc32, %eax
    118 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    119 ; X64-NEXT:  .LBB3_1: # %atomicrmw.start
    120 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    121 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    122 ; X64-NEXT:    movl %eax, %ecx
    123 ; X64-NEXT:    orl $5, %ecx
    124 ; X64-NEXT:    lock cmpxchgl %ecx, {{.*}}(%rip)
    125 ; X64-NEXT:    sete %dl
    126 ; X64-NEXT:    testb $1, %dl
    127 ; X64-NEXT:    movl %eax, %ecx
    128 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    129 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    130 ; X64-NEXT:    jne .LBB3_2
    131 ; X64-NEXT:    jmp .LBB3_1
    132 ; X64-NEXT:  .LBB3_2: # %atomicrmw.end
    133 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    134 ; X64-NEXT:    lock orl %eax, {{.*}}(%rip)
    135 ; X64-NEXT:    retq
    136 ;
    137 ; X86-LABEL: atomic_fetch_or32:
    138 ; X86:       # %bb.0:
    139 ; X86-NEXT:    subl $8, %esp
    140 ; X86-NEXT:    lock orl $3, sc32
    141 ; X86-NEXT:    movl sc32, %eax
    142 ; X86-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    143 ; X86-NEXT:  .LBB3_1: # %atomicrmw.start
    144 ; X86-NEXT:    # =>This Inner Loop Header: Depth=1
    145 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    146 ; X86-NEXT:    movl %eax, %ecx
    147 ; X86-NEXT:    orl $5, %ecx
    148 ; X86-NEXT:    lock cmpxchgl %ecx, sc32
    149 ; X86-NEXT:    sete %dl
    150 ; X86-NEXT:    testb $1, %dl
    151 ; X86-NEXT:    movl %eax, %ecx
    152 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
    153 ; X86-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    154 ; X86-NEXT:    jne .LBB3_2
    155 ; X86-NEXT:    jmp .LBB3_1
    156 ; X86-NEXT:  .LBB3_2: # %atomicrmw.end
    157 ; X86-NEXT:    movl (%esp), %eax # 4-byte Reload
    158 ; X86-NEXT:    lock orl %eax, sc32
    159 ; X86-NEXT:    addl $8, %esp
    160 ; X86-NEXT:    retl
    161   %t1 = atomicrmw or   i32* @sc32, i32 3 acquire
    162   %t2 = atomicrmw or   i32* @sc32, i32 5 acquire
    163   %t3 = atomicrmw or   i32* @sc32, i32 %t2 acquire
    164   ret void
    165 }
    166 
    167 define void @atomic_fetch_xor32() nounwind {
    168 ; X64-LABEL: atomic_fetch_xor32:
    169 ; X64:       # %bb.0:
    170 ; X64-NEXT:    lock xorl $3, {{.*}}(%rip)
    171 ; X64-NEXT:    movl sc32, %eax
    172 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    173 ; X64-NEXT:  .LBB4_1: # %atomicrmw.start
    174 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    175 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    176 ; X64-NEXT:    movl %eax, %ecx
    177 ; X64-NEXT:    xorl $5, %ecx
    178 ; X64-NEXT:    lock cmpxchgl %ecx, {{.*}}(%rip)
    179 ; X64-NEXT:    sete %dl
    180 ; X64-NEXT:    testb $1, %dl
    181 ; X64-NEXT:    movl %eax, %ecx
    182 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    183 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    184 ; X64-NEXT:    jne .LBB4_2
    185 ; X64-NEXT:    jmp .LBB4_1
    186 ; X64-NEXT:  .LBB4_2: # %atomicrmw.end
    187 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    188 ; X64-NEXT:    lock xorl %eax, {{.*}}(%rip)
    189 ; X64-NEXT:    retq
    190 ;
    191 ; X86-LABEL: atomic_fetch_xor32:
    192 ; X86:       # %bb.0:
    193 ; X86-NEXT:    subl $8, %esp
    194 ; X86-NEXT:    lock xorl $3, sc32
    195 ; X86-NEXT:    movl sc32, %eax
    196 ; X86-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    197 ; X86-NEXT:  .LBB4_1: # %atomicrmw.start
    198 ; X86-NEXT:    # =>This Inner Loop Header: Depth=1
    199 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    200 ; X86-NEXT:    movl %eax, %ecx
    201 ; X86-NEXT:    xorl $5, %ecx
    202 ; X86-NEXT:    lock cmpxchgl %ecx, sc32
    203 ; X86-NEXT:    sete %dl
    204 ; X86-NEXT:    testb $1, %dl
    205 ; X86-NEXT:    movl %eax, %ecx
    206 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
    207 ; X86-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    208 ; X86-NEXT:    jne .LBB4_2
    209 ; X86-NEXT:    jmp .LBB4_1
    210 ; X86-NEXT:  .LBB4_2: # %atomicrmw.end
    211 ; X86-NEXT:    movl (%esp), %eax # 4-byte Reload
    212 ; X86-NEXT:    lock xorl %eax, sc32
    213 ; X86-NEXT:    addl $8, %esp
    214 ; X86-NEXT:    retl
    215   %t1 = atomicrmw xor  i32* @sc32, i32 3 acquire
    216   %t2 = atomicrmw xor  i32* @sc32, i32 5 acquire
    217   %t3 = atomicrmw xor  i32* @sc32, i32 %t2 acquire
    218   ret void
    219 }
    220 
    221 define void @atomic_fetch_nand32(i32 %x) nounwind {
    222 ; X64-LABEL: atomic_fetch_nand32:
    223 ; X64:       # %bb.0:
    224 ; X64-NEXT:    movl sc32, %eax
    225 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    226 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    227 ; X64-NEXT:  .LBB5_1: # %atomicrmw.start
    228 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    229 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    230 ; X64-NEXT:    movl %eax, %ecx
    231 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %edx # 4-byte Reload
    232 ; X64-NEXT:    andl %edx, %ecx
    233 ; X64-NEXT:    notl %ecx
    234 ; X64-NEXT:    lock cmpxchgl %ecx, {{.*}}(%rip)
    235 ; X64-NEXT:    sete %sil
    236 ; X64-NEXT:    testb $1, %sil
    237 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    238 ; X64-NEXT:    jne .LBB5_2
    239 ; X64-NEXT:    jmp .LBB5_1
    240 ; X64-NEXT:  .LBB5_2: # %atomicrmw.end
    241 ; X64-NEXT:    retq
    242 ;
    243 ; X86-LABEL: atomic_fetch_nand32:
    244 ; X86:       # %bb.0:
    245 ; X86-NEXT:    pushl %ebx
    246 ; X86-NEXT:    subl $8, %esp
    247 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
    248 ; X86-NEXT:    movl sc32, %ecx
    249 ; X86-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    250 ; X86-NEXT:    movl %ecx, (%esp) # 4-byte Spill
    251 ; X86-NEXT:  .LBB5_1: # %atomicrmw.start
    252 ; X86-NEXT:    # =>This Inner Loop Header: Depth=1
    253 ; X86-NEXT:    movl (%esp), %eax # 4-byte Reload
    254 ; X86-NEXT:    movl %eax, %ecx
    255 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    256 ; X86-NEXT:    andl %edx, %ecx
    257 ; X86-NEXT:    notl %ecx
    258 ; X86-NEXT:    lock cmpxchgl %ecx, sc32
    259 ; X86-NEXT:    sete %bl
    260 ; X86-NEXT:    testb $1, %bl
    261 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
    262 ; X86-NEXT:    jne .LBB5_2
    263 ; X86-NEXT:    jmp .LBB5_1
    264 ; X86-NEXT:  .LBB5_2: # %atomicrmw.end
    265 ; X86-NEXT:    addl $8, %esp
    266 ; X86-NEXT:    popl %ebx
    267 ; X86-NEXT:    retl
    268   %t1 = atomicrmw nand i32* @sc32, i32 %x acquire
    269   ret void
    270 }
    271 
    272 define void @atomic_fetch_max32(i32 %x) nounwind {
    273 ; X64-LABEL: atomic_fetch_max32:
    274 ; X64:       # %bb.0:
    275 ; X64-NEXT:    movl sc32, %eax
    276 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    277 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    278 ; X64-NEXT:  .LBB6_1: # %atomicrmw.start
    279 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    280 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    281 ; X64-NEXT:    movl %eax, %ecx
    282 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %edx # 4-byte Reload
    283 ; X64-NEXT:    subl %edx, %ecx
    284 ; X64-NEXT:    cmovgel %eax, %edx
    285 ; X64-NEXT:    lock cmpxchgl %edx, {{.*}}(%rip)
    286 ; X64-NEXT:    sete %sil
    287 ; X64-NEXT:    testb $1, %sil
    288 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    289 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    290 ; X64-NEXT:    jne .LBB6_2
    291 ; X64-NEXT:    jmp .LBB6_1
    292 ; X64-NEXT:  .LBB6_2: # %atomicrmw.end
    293 ; X64-NEXT:    retq
    294 ;
    295 ; X86-CMOV-LABEL: atomic_fetch_max32:
    296 ; X86-CMOV:       # %bb.0:
    297 ; X86-CMOV-NEXT:    pushl %ebx
    298 ; X86-CMOV-NEXT:    subl $12, %esp
    299 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    300 ; X86-CMOV-NEXT:    movl sc32, %ecx
    301 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    302 ; X86-CMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    303 ; X86-CMOV-NEXT:  .LBB6_1: # %atomicrmw.start
    304 ; X86-CMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    305 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    306 ; X86-CMOV-NEXT:    movl %eax, %ecx
    307 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    308 ; X86-CMOV-NEXT:    subl %edx, %ecx
    309 ; X86-CMOV-NEXT:    cmovgel %eax, %edx
    310 ; X86-CMOV-NEXT:    lock cmpxchgl %edx, sc32
    311 ; X86-CMOV-NEXT:    sete %bl
    312 ; X86-CMOV-NEXT:    testb $1, %bl
    313 ; X86-CMOV-NEXT:    movl %ecx, (%esp) # 4-byte Spill
    314 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    315 ; X86-CMOV-NEXT:    jne .LBB6_2
    316 ; X86-CMOV-NEXT:    jmp .LBB6_1
    317 ; X86-CMOV-NEXT:  .LBB6_2: # %atomicrmw.end
    318 ; X86-CMOV-NEXT:    addl $12, %esp
    319 ; X86-CMOV-NEXT:    popl %ebx
    320 ; X86-CMOV-NEXT:    retl
    321 ;
    322 ; X86-NOCMOV-LABEL: atomic_fetch_max32:
    323 ; X86-NOCMOV:       # %bb.0:
    324 ; X86-NOCMOV-NEXT:    pushl %ebx
    325 ; X86-NOCMOV-NEXT:    pushl %esi
    326 ; X86-NOCMOV-NEXT:    subl $24, %esp
    327 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    328 ; X86-NOCMOV-NEXT:    movl sc32, %ecx
    329 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    330 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    331 ; X86-NOCMOV-NEXT:  .LBB6_1: # %atomicrmw.start
    332 ; X86-NOCMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    333 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    334 ; X86-NOCMOV-NEXT:    movl %eax, %ecx
    335 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    336 ; X86-NOCMOV-NEXT:    subl %edx, %ecx
    337 ; X86-NOCMOV-NEXT:    movl %eax, %esi
    338 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    339 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    340 ; X86-NOCMOV-NEXT:    movl %esi, {{[0-9]+}}(%esp) # 4-byte Spill
    341 ; X86-NOCMOV-NEXT:    jge .LBB6_4
    342 ; X86-NOCMOV-NEXT:  # %bb.3: # %atomicrmw.start
    343 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB6_1 Depth=1
    344 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    345 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    346 ; X86-NOCMOV-NEXT:  .LBB6_4: # %atomicrmw.start
    347 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB6_1 Depth=1
    348 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    349 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %ecx # 4-byte Reload
    350 ; X86-NOCMOV-NEXT:    movl %eax, (%esp) # 4-byte Spill
    351 ; X86-NOCMOV-NEXT:    movl %ecx, %eax
    352 ; X86-NOCMOV-NEXT:    movl (%esp), %edx # 4-byte Reload
    353 ; X86-NOCMOV-NEXT:    lock cmpxchgl %edx, sc32
    354 ; X86-NOCMOV-NEXT:    sete %bl
    355 ; X86-NOCMOV-NEXT:    testb $1, %bl
    356 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    357 ; X86-NOCMOV-NEXT:    jne .LBB6_2
    358 ; X86-NOCMOV-NEXT:    jmp .LBB6_1
    359 ; X86-NOCMOV-NEXT:  .LBB6_2: # %atomicrmw.end
    360 ; X86-NOCMOV-NEXT:    addl $24, %esp
    361 ; X86-NOCMOV-NEXT:    popl %esi
    362 ; X86-NOCMOV-NEXT:    popl %ebx
    363 ; X86-NOCMOV-NEXT:    retl
    364   %t1 = atomicrmw max  i32* @sc32, i32 %x acquire
    365   ret void
    366 }
    367 
    368 define void @atomic_fetch_min32(i32 %x) nounwind {
    369 ; X64-LABEL: atomic_fetch_min32:
    370 ; X64:       # %bb.0:
    371 ; X64-NEXT:    movl sc32, %eax
    372 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    373 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    374 ; X64-NEXT:  .LBB7_1: # %atomicrmw.start
    375 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    376 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    377 ; X64-NEXT:    movl %eax, %ecx
    378 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %edx # 4-byte Reload
    379 ; X64-NEXT:    subl %edx, %ecx
    380 ; X64-NEXT:    cmovlel %eax, %edx
    381 ; X64-NEXT:    lock cmpxchgl %edx, {{.*}}(%rip)
    382 ; X64-NEXT:    sete %sil
    383 ; X64-NEXT:    testb $1, %sil
    384 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    385 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    386 ; X64-NEXT:    jne .LBB7_2
    387 ; X64-NEXT:    jmp .LBB7_1
    388 ; X64-NEXT:  .LBB7_2: # %atomicrmw.end
    389 ; X64-NEXT:    retq
    390 ;
    391 ; X86-CMOV-LABEL: atomic_fetch_min32:
    392 ; X86-CMOV:       # %bb.0:
    393 ; X86-CMOV-NEXT:    pushl %ebx
    394 ; X86-CMOV-NEXT:    subl $12, %esp
    395 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    396 ; X86-CMOV-NEXT:    movl sc32, %ecx
    397 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    398 ; X86-CMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    399 ; X86-CMOV-NEXT:  .LBB7_1: # %atomicrmw.start
    400 ; X86-CMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    401 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    402 ; X86-CMOV-NEXT:    movl %eax, %ecx
    403 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    404 ; X86-CMOV-NEXT:    subl %edx, %ecx
    405 ; X86-CMOV-NEXT:    cmovlel %eax, %edx
    406 ; X86-CMOV-NEXT:    lock cmpxchgl %edx, sc32
    407 ; X86-CMOV-NEXT:    sete %bl
    408 ; X86-CMOV-NEXT:    testb $1, %bl
    409 ; X86-CMOV-NEXT:    movl %ecx, (%esp) # 4-byte Spill
    410 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    411 ; X86-CMOV-NEXT:    jne .LBB7_2
    412 ; X86-CMOV-NEXT:    jmp .LBB7_1
    413 ; X86-CMOV-NEXT:  .LBB7_2: # %atomicrmw.end
    414 ; X86-CMOV-NEXT:    addl $12, %esp
    415 ; X86-CMOV-NEXT:    popl %ebx
    416 ; X86-CMOV-NEXT:    retl
    417 ;
    418 ; X86-NOCMOV-LABEL: atomic_fetch_min32:
    419 ; X86-NOCMOV:       # %bb.0:
    420 ; X86-NOCMOV-NEXT:    pushl %ebx
    421 ; X86-NOCMOV-NEXT:    pushl %esi
    422 ; X86-NOCMOV-NEXT:    subl $24, %esp
    423 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    424 ; X86-NOCMOV-NEXT:    movl sc32, %ecx
    425 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    426 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    427 ; X86-NOCMOV-NEXT:  .LBB7_1: # %atomicrmw.start
    428 ; X86-NOCMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    429 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    430 ; X86-NOCMOV-NEXT:    movl %eax, %ecx
    431 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    432 ; X86-NOCMOV-NEXT:    subl %edx, %ecx
    433 ; X86-NOCMOV-NEXT:    movl %eax, %esi
    434 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    435 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    436 ; X86-NOCMOV-NEXT:    movl %esi, {{[0-9]+}}(%esp) # 4-byte Spill
    437 ; X86-NOCMOV-NEXT:    jle .LBB7_4
    438 ; X86-NOCMOV-NEXT:  # %bb.3: # %atomicrmw.start
    439 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB7_1 Depth=1
    440 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    441 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    442 ; X86-NOCMOV-NEXT:  .LBB7_4: # %atomicrmw.start
    443 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB7_1 Depth=1
    444 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    445 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %ecx # 4-byte Reload
    446 ; X86-NOCMOV-NEXT:    movl %eax, (%esp) # 4-byte Spill
    447 ; X86-NOCMOV-NEXT:    movl %ecx, %eax
    448 ; X86-NOCMOV-NEXT:    movl (%esp), %edx # 4-byte Reload
    449 ; X86-NOCMOV-NEXT:    lock cmpxchgl %edx, sc32
    450 ; X86-NOCMOV-NEXT:    sete %bl
    451 ; X86-NOCMOV-NEXT:    testb $1, %bl
    452 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    453 ; X86-NOCMOV-NEXT:    jne .LBB7_2
    454 ; X86-NOCMOV-NEXT:    jmp .LBB7_1
    455 ; X86-NOCMOV-NEXT:  .LBB7_2: # %atomicrmw.end
    456 ; X86-NOCMOV-NEXT:    addl $24, %esp
    457 ; X86-NOCMOV-NEXT:    popl %esi
    458 ; X86-NOCMOV-NEXT:    popl %ebx
    459 ; X86-NOCMOV-NEXT:    retl
    460   %t1 = atomicrmw min  i32* @sc32, i32 %x acquire
    461   ret void
    462 }
    463 
    464 define void @atomic_fetch_umax32(i32 %x) nounwind {
    465 ; X64-LABEL: atomic_fetch_umax32:
    466 ; X64:       # %bb.0:
    467 ; X64-NEXT:    movl sc32, %eax
    468 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    469 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    470 ; X64-NEXT:  .LBB8_1: # %atomicrmw.start
    471 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    472 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    473 ; X64-NEXT:    movl %eax, %ecx
    474 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %edx # 4-byte Reload
    475 ; X64-NEXT:    subl %edx, %ecx
    476 ; X64-NEXT:    cmoval %eax, %edx
    477 ; X64-NEXT:    lock cmpxchgl %edx, {{.*}}(%rip)
    478 ; X64-NEXT:    sete %sil
    479 ; X64-NEXT:    testb $1, %sil
    480 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    481 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    482 ; X64-NEXT:    jne .LBB8_2
    483 ; X64-NEXT:    jmp .LBB8_1
    484 ; X64-NEXT:  .LBB8_2: # %atomicrmw.end
    485 ; X64-NEXT:    retq
    486 ;
    487 ; X86-CMOV-LABEL: atomic_fetch_umax32:
    488 ; X86-CMOV:       # %bb.0:
    489 ; X86-CMOV-NEXT:    pushl %ebx
    490 ; X86-CMOV-NEXT:    subl $12, %esp
    491 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    492 ; X86-CMOV-NEXT:    movl sc32, %ecx
    493 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    494 ; X86-CMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    495 ; X86-CMOV-NEXT:  .LBB8_1: # %atomicrmw.start
    496 ; X86-CMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    497 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    498 ; X86-CMOV-NEXT:    movl %eax, %ecx
    499 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    500 ; X86-CMOV-NEXT:    subl %edx, %ecx
    501 ; X86-CMOV-NEXT:    cmoval %eax, %edx
    502 ; X86-CMOV-NEXT:    lock cmpxchgl %edx, sc32
    503 ; X86-CMOV-NEXT:    sete %bl
    504 ; X86-CMOV-NEXT:    testb $1, %bl
    505 ; X86-CMOV-NEXT:    movl %ecx, (%esp) # 4-byte Spill
    506 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    507 ; X86-CMOV-NEXT:    jne .LBB8_2
    508 ; X86-CMOV-NEXT:    jmp .LBB8_1
    509 ; X86-CMOV-NEXT:  .LBB8_2: # %atomicrmw.end
    510 ; X86-CMOV-NEXT:    addl $12, %esp
    511 ; X86-CMOV-NEXT:    popl %ebx
    512 ; X86-CMOV-NEXT:    retl
    513 ;
    514 ; X86-NOCMOV-LABEL: atomic_fetch_umax32:
    515 ; X86-NOCMOV:       # %bb.0:
    516 ; X86-NOCMOV-NEXT:    pushl %ebx
    517 ; X86-NOCMOV-NEXT:    pushl %esi
    518 ; X86-NOCMOV-NEXT:    subl $24, %esp
    519 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    520 ; X86-NOCMOV-NEXT:    movl sc32, %ecx
    521 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    522 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    523 ; X86-NOCMOV-NEXT:  .LBB8_1: # %atomicrmw.start
    524 ; X86-NOCMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    525 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    526 ; X86-NOCMOV-NEXT:    movl %eax, %ecx
    527 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    528 ; X86-NOCMOV-NEXT:    subl %edx, %ecx
    529 ; X86-NOCMOV-NEXT:    movl %eax, %esi
    530 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    531 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    532 ; X86-NOCMOV-NEXT:    movl %esi, {{[0-9]+}}(%esp) # 4-byte Spill
    533 ; X86-NOCMOV-NEXT:    ja .LBB8_4
    534 ; X86-NOCMOV-NEXT:  # %bb.3: # %atomicrmw.start
    535 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB8_1 Depth=1
    536 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    537 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    538 ; X86-NOCMOV-NEXT:  .LBB8_4: # %atomicrmw.start
    539 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB8_1 Depth=1
    540 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    541 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %ecx # 4-byte Reload
    542 ; X86-NOCMOV-NEXT:    movl %eax, (%esp) # 4-byte Spill
    543 ; X86-NOCMOV-NEXT:    movl %ecx, %eax
    544 ; X86-NOCMOV-NEXT:    movl (%esp), %edx # 4-byte Reload
    545 ; X86-NOCMOV-NEXT:    lock cmpxchgl %edx, sc32
    546 ; X86-NOCMOV-NEXT:    sete %bl
    547 ; X86-NOCMOV-NEXT:    testb $1, %bl
    548 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    549 ; X86-NOCMOV-NEXT:    jne .LBB8_2
    550 ; X86-NOCMOV-NEXT:    jmp .LBB8_1
    551 ; X86-NOCMOV-NEXT:  .LBB8_2: # %atomicrmw.end
    552 ; X86-NOCMOV-NEXT:    addl $24, %esp
    553 ; X86-NOCMOV-NEXT:    popl %esi
    554 ; X86-NOCMOV-NEXT:    popl %ebx
    555 ; X86-NOCMOV-NEXT:    retl
    556   %t1 = atomicrmw umax i32* @sc32, i32 %x acquire
    557   ret void
    558 }
    559 
    560 define void @atomic_fetch_umin32(i32 %x) nounwind {
    561 ; X64-LABEL: atomic_fetch_umin32:
    562 ; X64:       # %bb.0:
    563 ; X64-NEXT:    movl sc32, %eax
    564 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    565 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    566 ; X64-NEXT:  .LBB9_1: # %atomicrmw.start
    567 ; X64-NEXT:    # =>This Inner Loop Header: Depth=1
    568 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %eax # 4-byte Reload
    569 ; X64-NEXT:    movl %eax, %ecx
    570 ; X64-NEXT:    movl -{{[0-9]+}}(%rsp), %edx # 4-byte Reload
    571 ; X64-NEXT:    subl %edx, %ecx
    572 ; X64-NEXT:    cmovbel %eax, %edx
    573 ; X64-NEXT:    lock cmpxchgl %edx, {{.*}}(%rip)
    574 ; X64-NEXT:    sete %sil
    575 ; X64-NEXT:    testb $1, %sil
    576 ; X64-NEXT:    movl %ecx, -{{[0-9]+}}(%rsp) # 4-byte Spill
    577 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    578 ; X64-NEXT:    jne .LBB9_2
    579 ; X64-NEXT:    jmp .LBB9_1
    580 ; X64-NEXT:  .LBB9_2: # %atomicrmw.end
    581 ; X64-NEXT:    retq
    582 ;
    583 ; X86-CMOV-LABEL: atomic_fetch_umin32:
    584 ; X86-CMOV:       # %bb.0:
    585 ; X86-CMOV-NEXT:    pushl %ebx
    586 ; X86-CMOV-NEXT:    subl $12, %esp
    587 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    588 ; X86-CMOV-NEXT:    movl sc32, %ecx
    589 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    590 ; X86-CMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    591 ; X86-CMOV-NEXT:  .LBB9_1: # %atomicrmw.start
    592 ; X86-CMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    593 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    594 ; X86-CMOV-NEXT:    movl %eax, %ecx
    595 ; X86-CMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    596 ; X86-CMOV-NEXT:    subl %edx, %ecx
    597 ; X86-CMOV-NEXT:    cmovbel %eax, %edx
    598 ; X86-CMOV-NEXT:    lock cmpxchgl %edx, sc32
    599 ; X86-CMOV-NEXT:    sete %bl
    600 ; X86-CMOV-NEXT:    testb $1, %bl
    601 ; X86-CMOV-NEXT:    movl %ecx, (%esp) # 4-byte Spill
    602 ; X86-CMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    603 ; X86-CMOV-NEXT:    jne .LBB9_2
    604 ; X86-CMOV-NEXT:    jmp .LBB9_1
    605 ; X86-CMOV-NEXT:  .LBB9_2: # %atomicrmw.end
    606 ; X86-CMOV-NEXT:    addl $12, %esp
    607 ; X86-CMOV-NEXT:    popl %ebx
    608 ; X86-CMOV-NEXT:    retl
    609 ;
    610 ; X86-NOCMOV-LABEL: atomic_fetch_umin32:
    611 ; X86-NOCMOV:       # %bb.0:
    612 ; X86-NOCMOV-NEXT:    pushl %ebx
    613 ; X86-NOCMOV-NEXT:    pushl %esi
    614 ; X86-NOCMOV-NEXT:    subl $24, %esp
    615 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax
    616 ; X86-NOCMOV-NEXT:    movl sc32, %ecx
    617 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    618 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    619 ; X86-NOCMOV-NEXT:  .LBB9_1: # %atomicrmw.start
    620 ; X86-NOCMOV-NEXT:    # =>This Inner Loop Header: Depth=1
    621 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    622 ; X86-NOCMOV-NEXT:    movl %eax, %ecx
    623 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %edx # 4-byte Reload
    624 ; X86-NOCMOV-NEXT:    subl %edx, %ecx
    625 ; X86-NOCMOV-NEXT:    movl %eax, %esi
    626 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    627 ; X86-NOCMOV-NEXT:    movl %ecx, {{[0-9]+}}(%esp) # 4-byte Spill
    628 ; X86-NOCMOV-NEXT:    movl %esi, {{[0-9]+}}(%esp) # 4-byte Spill
    629 ; X86-NOCMOV-NEXT:    jbe .LBB9_4
    630 ; X86-NOCMOV-NEXT:  # %bb.3: # %atomicrmw.start
    631 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB9_1 Depth=1
    632 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    633 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    634 ; X86-NOCMOV-NEXT:  .LBB9_4: # %atomicrmw.start
    635 ; X86-NOCMOV-NEXT:    # in Loop: Header=BB9_1 Depth=1
    636 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %eax # 4-byte Reload
    637 ; X86-NOCMOV-NEXT:    movl {{[0-9]+}}(%esp), %ecx # 4-byte Reload
    638 ; X86-NOCMOV-NEXT:    movl %eax, (%esp) # 4-byte Spill
    639 ; X86-NOCMOV-NEXT:    movl %ecx, %eax
    640 ; X86-NOCMOV-NEXT:    movl (%esp), %edx # 4-byte Reload
    641 ; X86-NOCMOV-NEXT:    lock cmpxchgl %edx, sc32
    642 ; X86-NOCMOV-NEXT:    sete %bl
    643 ; X86-NOCMOV-NEXT:    testb $1, %bl
    644 ; X86-NOCMOV-NEXT:    movl %eax, {{[0-9]+}}(%esp) # 4-byte Spill
    645 ; X86-NOCMOV-NEXT:    jne .LBB9_2
    646 ; X86-NOCMOV-NEXT:    jmp .LBB9_1
    647 ; X86-NOCMOV-NEXT:  .LBB9_2: # %atomicrmw.end
    648 ; X86-NOCMOV-NEXT:    addl $24, %esp
    649 ; X86-NOCMOV-NEXT:    popl %esi
    650 ; X86-NOCMOV-NEXT:    popl %ebx
    651 ; X86-NOCMOV-NEXT:    retl
    652   %t1 = atomicrmw umin i32* @sc32, i32 %x acquire
    653   ret void
    654 }
    655 
    656 define void @atomic_fetch_cmpxchg32() nounwind {
    657 ; X64-LABEL: atomic_fetch_cmpxchg32:
    658 ; X64:       # %bb.0:
    659 ; X64-NEXT:    xorl %eax, %eax
    660 ; X64-NEXT:    movl $1, %ecx
    661 ; X64-NEXT:    lock cmpxchgl %ecx, {{.*}}(%rip)
    662 ; X64-NEXT:    movl %eax, -{{[0-9]+}}(%rsp) # 4-byte Spill
    663 ; X64-NEXT:    retq
    664 ;
    665 ; X86-LABEL: atomic_fetch_cmpxchg32:
    666 ; X86:       # %bb.0:
    667 ; X86-NEXT:    pushl %eax
    668 ; X86-NEXT:    xorl %eax, %eax
    669 ; X86-NEXT:    movl $1, %ecx
    670 ; X86-NEXT:    lock cmpxchgl %ecx, sc32
    671 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
    672 ; X86-NEXT:    popl %eax
    673 ; X86-NEXT:    retl
    674   %t1 = cmpxchg i32* @sc32, i32 0, i32 1 acquire acquire
    675   ret void
    676 }
    677 
    678 define void @atomic_fetch_store32(i32 %x) nounwind {
    679 ; X64-LABEL: atomic_fetch_store32:
    680 ; X64:       # %bb.0:
    681 ; X64-NEXT:    movl %edi, {{.*}}(%rip)
    682 ; X64-NEXT:    retq
    683 ;
    684 ; X86-LABEL: atomic_fetch_store32:
    685 ; X86:       # %bb.0:
    686 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
    687 ; X86-NEXT:    movl %eax, sc32
    688 ; X86-NEXT:    retl
    689   store atomic i32 %x, i32* @sc32 release, align 4
    690   ret void
    691 }
    692 
    693 define void @atomic_fetch_swap32(i32 %x) nounwind {
    694 ; X64-LABEL: atomic_fetch_swap32:
    695 ; X64:       # %bb.0:
    696 ; X64-NEXT:    xchgl %edi, {{.*}}(%rip)
    697 ; X64-NEXT:    movl %edi, -{{[0-9]+}}(%rsp) # 4-byte Spill
    698 ; X64-NEXT:    retq
    699 ;
    700 ; X86-LABEL: atomic_fetch_swap32:
    701 ; X86:       # %bb.0:
    702 ; X86-NEXT:    pushl %eax
    703 ; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax
    704 ; X86-NEXT:    xchgl %eax, sc32
    705 ; X86-NEXT:    movl %eax, (%esp) # 4-byte Spill
    706 ; X86-NEXT:    popl %eax
    707 ; X86-NEXT:    retl
    708   %t1 = atomicrmw xchg i32* @sc32, i32 %x acquire
    709   ret void
    710 }
    711