Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s -mcpu=generic -march=x86 -mattr=+cmov,cx16 -verify-machineinstrs | FileCheck %s
      2 
      3 target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128"
      4 
      5 define void @func(i32 %argc, i8** %argv) nounwind {
      6 entry:
      7 	%argc.addr = alloca i32		; <i32*> [#uses=1]
      8 	%argv.addr = alloca i8**		; <i8***> [#uses=1]
      9 	%val1 = alloca i32		; <i32*> [#uses=2]
     10 	%val2 = alloca i32		; <i32*> [#uses=15]
     11 	%andt = alloca i32		; <i32*> [#uses=2]
     12 	%ort = alloca i32		; <i32*> [#uses=2]
     13 	%xort = alloca i32		; <i32*> [#uses=2]
     14 	%old = alloca i32		; <i32*> [#uses=18]
     15 	%temp = alloca i32		; <i32*> [#uses=2]
     16 	%temp64 = alloca i64
     17 	store i32 %argc, i32* %argc.addr
     18 	store i8** %argv, i8*** %argv.addr
     19 	store i32 0, i32* %val1
     20 	store i32 31, i32* %val2
     21 	store i32 3855, i32* %andt
     22 	store i32 3855, i32* %ort
     23 	store i32 3855, i32* %xort
     24 	store i32 4, i32* %temp
     25 	%tmp = load i32* %temp
     26         ; CHECK: lock
     27         ; CHECK: xaddl
     28   %0 = atomicrmw add i32* %val1, i32 %tmp monotonic
     29 	store i32 %0, i32* %old
     30         ; CHECK: lock
     31         ; CHECK: xaddl
     32   %1 = atomicrmw sub i32* %val2, i32 30 monotonic
     33 	store i32 %1, i32* %old
     34         ; CHECK: lock
     35         ; CHECK: xaddl
     36   %2 = atomicrmw add i32* %val2, i32 1 monotonic
     37 	store i32 %2, i32* %old
     38         ; CHECK: lock
     39         ; CHECK: xaddl
     40   %3 = atomicrmw sub i32* %val2, i32 1 monotonic
     41 	store i32 %3, i32* %old
     42         ; CHECK: andl
     43         ; CHECK: lock
     44         ; CHECK: cmpxchgl
     45   %4 = atomicrmw and i32* %andt, i32 4080 monotonic
     46 	store i32 %4, i32* %old
     47         ; CHECK: orl
     48         ; CHECK: lock
     49         ; CHECK: cmpxchgl
     50   %5 = atomicrmw or i32* %ort, i32 4080 monotonic
     51 	store i32 %5, i32* %old
     52         ; CHECK: xorl
     53         ; CHECK: lock
     54         ; CHECK: cmpxchgl
     55   %6 = atomicrmw xor i32* %xort, i32 4080 monotonic
     56 	store i32 %6, i32* %old
     57         ; CHECK: cmov
     58         ; CHECK: lock
     59         ; CHECK: cmpxchgl
     60   %7 = atomicrmw min i32* %val2, i32 16 monotonic
     61 	store i32 %7, i32* %old
     62 	%neg = sub i32 0, 1		; <i32> [#uses=1]
     63         ; CHECK: cmov
     64         ; CHECK: lock
     65         ; CHECK: cmpxchgl
     66   %8 = atomicrmw min i32* %val2, i32 %neg monotonic
     67 	store i32 %8, i32* %old
     68         ; CHECK: cmov
     69         ; CHECK: lock
     70         ; CHECK: cmpxchgl
     71   %9 = atomicrmw max i32* %val2, i32 1 monotonic
     72 	store i32 %9, i32* %old
     73         ; CHECK: cmov
     74         ; CHECK: lock
     75         ; CHECK: cmpxchgl
     76   %10 = atomicrmw max i32* %val2, i32 0 monotonic
     77 	store i32 %10, i32* %old
     78         ; CHECK: cmov
     79         ; CHECK: lock
     80         ; CHECK: cmpxchgl
     81   %11 = atomicrmw umax i32* %val2, i32 65535 monotonic
     82 	store i32 %11, i32* %old
     83         ; CHECK: cmov
     84         ; CHECK: lock
     85         ; CHECK: cmpxchgl
     86   %12 = atomicrmw umax i32* %val2, i32 10 monotonic
     87 	store i32 %12, i32* %old
     88         ; CHECK: cmov
     89         ; CHECK: lock
     90         ; CHECK: cmpxchgl
     91   %13 = atomicrmw umin i32* %val2, i32 1 monotonic
     92 	store i32 %13, i32* %old
     93         ; CHECK: cmov
     94         ; CHECK: lock
     95         ; CHECK: cmpxchgl
     96   %14 = atomicrmw umin i32* %val2, i32 10 monotonic
     97 	store i32 %14, i32* %old
     98         ; CHECK: xchgl   %{{.*}}, {{.*}}(%esp)
     99   %15 = atomicrmw xchg i32* %val2, i32 1976 monotonic
    100 	store i32 %15, i32* %old
    101 	%neg1 = sub i32 0, 10		; <i32> [#uses=1]
    102         ; CHECK: lock
    103         ; CHECK: cmpxchgl
    104   %pair16 = cmpxchg i32* %val2, i32 %neg1, i32 1 monotonic monotonic
    105   %16 = extractvalue { i32, i1 } %pair16, 0
    106 	store i32 %16, i32* %old
    107         ; CHECK: lock
    108         ; CHECK: cmpxchgl
    109   %pair17 = cmpxchg i32* %val2, i32 1976, i32 1 monotonic monotonic
    110   %17 = extractvalue { i32, i1 } %pair17, 0
    111 	store i32 %17, i32* %old
    112         ; CHECK: movl  [[R17atomic:.*]], %eax
    113         ; CHECK: movl %eax, %[[R17mask:[a-z]*]]
    114         ; CHECK: notl %[[R17mask]]
    115         ; CHECK: orl $-1402, %[[R17mask]]
    116         ; CHECK: lock
    117         ; CHECK: cmpxchgl	%[[R17mask]], [[R17atomic]]
    118         ; CHECK: jne
    119         ; CHECK: movl	%eax,
    120   %18 = atomicrmw nand i32* %val2, i32 1401 monotonic
    121   store i32 %18, i32* %old
    122         ; CHECK: notl
    123         ; CHECK: notl
    124         ; CHECK: orl $252645135
    125         ; CHECK: orl $252645135
    126         ; CHECK: lock
    127         ; CHECK: cmpxchg8b
    128   %19 = atomicrmw nand i64* %temp64, i64 17361641481138401520 monotonic
    129   store i64 %19, i64* %temp64
    130 	ret void
    131 }
    132 
    133 define void @test2(i32 addrspace(256)* nocapture %P) nounwind {
    134 entry:
    135 ; CHECK: lock
    136 ; CHECK:	cmpxchgl	%{{.*}}, %gs:(%{{.*}})
    137 
    138   %pair0 = cmpxchg i32 addrspace(256)* %P, i32 0, i32 1 monotonic monotonic
    139   %0 = extractvalue { i32, i1 } %pair0, 0
    140   ret void
    141 }
    142