1 ; RUN: llc < %s -march=x86 | 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 store i32 %argc, i32* %argc.addr 17 store i8** %argv, i8*** %argv.addr 18 store i32 0, i32* %val1 19 store i32 31, i32* %val2 20 store i32 3855, i32* %andt 21 store i32 3855, i32* %ort 22 store i32 3855, i32* %xort 23 store i32 4, i32* %temp 24 %tmp = load i32* %temp 25 ; CHECK: lock 26 ; CHECK: xaddl 27 %0 = atomicrmw add i32* %val1, i32 %tmp monotonic 28 store i32 %0, i32* %old 29 ; CHECK: lock 30 ; CHECK: xaddl 31 %1 = atomicrmw sub i32* %val2, i32 30 monotonic 32 store i32 %1, i32* %old 33 ; CHECK: lock 34 ; CHECK: xaddl 35 %2 = atomicrmw add i32* %val2, i32 1 monotonic 36 store i32 %2, i32* %old 37 ; CHECK: lock 38 ; CHECK: xaddl 39 %3 = atomicrmw sub i32* %val2, i32 1 monotonic 40 store i32 %3, i32* %old 41 ; CHECK: andl 42 ; CHECK: lock 43 ; CHECK: cmpxchgl 44 %4 = atomicrmw and i32* %andt, i32 4080 monotonic 45 store i32 %4, i32* %old 46 ; CHECK: orl 47 ; CHECK: lock 48 ; CHECK: cmpxchgl 49 %5 = atomicrmw or i32* %ort, i32 4080 monotonic 50 store i32 %5, i32* %old 51 ; CHECK: xorl 52 ; CHECK: lock 53 ; CHECK: cmpxchgl 54 %6 = atomicrmw xor i32* %xort, i32 4080 monotonic 55 store i32 %6, i32* %old 56 ; CHECK: cmov 57 ; CHECK: lock 58 ; CHECK: cmpxchgl 59 %7 = atomicrmw min i32* %val2, i32 16 monotonic 60 store i32 %7, i32* %old 61 %neg = sub i32 0, 1 ; <i32> [#uses=1] 62 ; CHECK: cmov 63 ; CHECK: lock 64 ; CHECK: cmpxchgl 65 %8 = atomicrmw min i32* %val2, i32 %neg monotonic 66 store i32 %8, i32* %old 67 ; CHECK: cmov 68 ; CHECK: lock 69 ; CHECK: cmpxchgl 70 %9 = atomicrmw max i32* %val2, i32 1 monotonic 71 store i32 %9, i32* %old 72 ; CHECK: cmov 73 ; CHECK: lock 74 ; CHECK: cmpxchgl 75 %10 = atomicrmw max i32* %val2, i32 0 monotonic 76 store i32 %10, i32* %old 77 ; CHECK: cmov 78 ; CHECK: lock 79 ; CHECK: cmpxchgl 80 %11 = atomicrmw umax i32* %val2, i32 65535 monotonic 81 store i32 %11, i32* %old 82 ; CHECK: cmov 83 ; CHECK: lock 84 ; CHECK: cmpxchgl 85 %12 = atomicrmw umax i32* %val2, i32 10 monotonic 86 store i32 %12, i32* %old 87 ; CHECK: cmov 88 ; CHECK: lock 89 ; CHECK: cmpxchgl 90 %13 = atomicrmw umin i32* %val2, i32 1 monotonic 91 store i32 %13, i32* %old 92 ; CHECK: cmov 93 ; CHECK: lock 94 ; CHECK: cmpxchgl 95 %14 = atomicrmw umin i32* %val2, i32 10 monotonic 96 store i32 %14, i32* %old 97 ; CHECK: xchgl %{{.*}}, {{.*}}(%esp) 98 %15 = atomicrmw xchg i32* %val2, i32 1976 monotonic 99 store i32 %15, i32* %old 100 %neg1 = sub i32 0, 10 ; <i32> [#uses=1] 101 ; CHECK: lock 102 ; CHECK: cmpxchgl 103 %16 = cmpxchg i32* %val2, i32 %neg1, i32 1 monotonic 104 store i32 %16, i32* %old 105 ; CHECK: lock 106 ; CHECK: cmpxchgl 107 %17 = cmpxchg i32* %val2, i32 1976, i32 1 monotonic 108 store i32 %17, i32* %old 109 ret void 110 } 111 112 define void @test2(i32 addrspace(256)* nocapture %P) nounwind { 113 entry: 114 ; CHECK: lock 115 ; CHECK: cmpxchgl %{{.*}}, %gs:(%{{.*}}) 116 117 %0 = cmpxchg i32 addrspace(256)* %P, i32 0, i32 1 monotonic 118 ret void 119 } 120