1; RUN: llc < %s -march=x86-64 -verify-machineinstrs | FileCheck %s 2; RUN: llc < %s -march=x86-64 -mattr=slow-incdec -verify-machineinstrs | FileCheck %s --check-prefix SLOW_INC 3 4; rdar://7103704 5 6define void @sub1(i32* nocapture %p, i32 %v) nounwind ssp { 7entry: 8; CHECK-LABEL: sub1: 9; CHECK: subl 10 %0 = atomicrmw sub i32* %p, i32 %v monotonic 11 ret void 12} 13 14define void @inc4(i64* nocapture %p) nounwind ssp { 15entry: 16; CHECK-LABEL: inc4: 17; CHECK: incq 18; SLOW_INC-LABEL: inc4: 19; SLOW_INC-NOT: incq 20 %0 = atomicrmw add i64* %p, i64 1 monotonic 21 ret void 22} 23 24define void @add8(i64* nocapture %p) nounwind ssp { 25entry: 26; CHECK-LABEL: add8: 27; CHECK: addq $2 28 %0 = atomicrmw add i64* %p, i64 2 monotonic 29 ret void 30} 31 32define void @add4(i64* nocapture %p, i32 %v) nounwind ssp { 33entry: 34; CHECK-LABEL: add4: 35; CHECK: addq 36 %0 = sext i32 %v to i64 ; <i64> [#uses=1] 37 %1 = atomicrmw add i64* %p, i64 %0 monotonic 38 ret void 39} 40 41define void @inc3(i8* nocapture %p) nounwind ssp { 42entry: 43; CHECK-LABEL: inc3: 44; CHECK: incb 45; SLOW_INC-LABEL: inc3: 46; SLOW_INC-NOT: incb 47 %0 = atomicrmw add i8* %p, i8 1 monotonic 48 ret void 49} 50 51define void @add7(i8* nocapture %p) nounwind ssp { 52entry: 53; CHECK-LABEL: add7: 54; CHECK: addb $2 55 %0 = atomicrmw add i8* %p, i8 2 monotonic 56 ret void 57} 58 59define void @add3(i8* nocapture %p, i32 %v) nounwind ssp { 60entry: 61; CHECK-LABEL: add3: 62; CHECK: addb 63 %0 = trunc i32 %v to i8 ; <i8> [#uses=1] 64 %1 = atomicrmw add i8* %p, i8 %0 monotonic 65 ret void 66} 67 68define void @inc2(i16* nocapture %p) nounwind ssp { 69entry: 70; CHECK-LABEL: inc2: 71; CHECK: incw 72; SLOW_INC-LABEL: inc2: 73; SLOW_INC-NOT: incw 74 %0 = atomicrmw add i16* %p, i16 1 monotonic 75 ret void 76} 77 78define void @add6(i16* nocapture %p) nounwind ssp { 79entry: 80; CHECK-LABEL: add6: 81; CHECK: addw $2 82 %0 = atomicrmw add i16* %p, i16 2 monotonic 83 ret void 84} 85 86define void @add2(i16* nocapture %p, i32 %v) nounwind ssp { 87entry: 88; CHECK-LABEL: add2: 89; CHECK: addw 90 %0 = trunc i32 %v to i16 ; <i16> [#uses=1] 91 %1 = atomicrmw add i16* %p, i16 %0 monotonic 92 ret void 93} 94 95define void @inc1(i32* nocapture %p) nounwind ssp { 96entry: 97; CHECK-LABEL: inc1: 98; CHECK: incl 99; SLOW_INC-LABEL: inc1: 100; SLOW_INC-NOT: incl 101 %0 = atomicrmw add i32* %p, i32 1 monotonic 102 ret void 103} 104 105define void @add5(i32* nocapture %p) nounwind ssp { 106entry: 107; CHECK-LABEL: add5: 108; CHECK: addl $2 109 %0 = atomicrmw add i32* %p, i32 2 monotonic 110 ret void 111} 112 113define void @add1(i32* nocapture %p, i32 %v) nounwind ssp { 114entry: 115; CHECK-LABEL: add1: 116; CHECK: addl 117 %0 = atomicrmw add i32* %p, i32 %v monotonic 118 ret void 119} 120 121define void @dec4(i64* nocapture %p) nounwind ssp { 122entry: 123; CHECK-LABEL: dec4: 124; CHECK: decq 125; SLOW_INC-LABEL: dec4: 126; SLOW_INC-NOT: decq 127 %0 = atomicrmw sub i64* %p, i64 1 monotonic 128 ret void 129} 130 131define void @sub8(i64* nocapture %p) nounwind ssp { 132entry: 133; CHECK-LABEL: sub8: 134; CHECK: subq $2 135 %0 = atomicrmw sub i64* %p, i64 2 monotonic 136 ret void 137} 138 139define void @sub4(i64* nocapture %p, i32 %v) nounwind ssp { 140entry: 141; CHECK-LABEL: sub4: 142; CHECK: subq 143 %0 = sext i32 %v to i64 ; <i64> [#uses=1] 144 %1 = atomicrmw sub i64* %p, i64 %0 monotonic 145 ret void 146} 147 148define void @dec3(i8* nocapture %p) nounwind ssp { 149entry: 150; CHECK-LABEL: dec3: 151; CHECK: decb 152; SLOW_INC-LABEL: dec3: 153; SLOW_INC-NOT: decb 154 %0 = atomicrmw sub i8* %p, i8 1 monotonic 155 ret void 156} 157 158define void @sub7(i8* nocapture %p) nounwind ssp { 159entry: 160; CHECK-LABEL: sub7: 161; CHECK: subb $2 162 %0 = atomicrmw sub i8* %p, i8 2 monotonic 163 ret void 164} 165 166define void @sub3(i8* nocapture %p, i32 %v) nounwind ssp { 167entry: 168; CHECK-LABEL: sub3: 169; CHECK: subb 170 %0 = trunc i32 %v to i8 ; <i8> [#uses=1] 171 %1 = atomicrmw sub i8* %p, i8 %0 monotonic 172 ret void 173} 174 175define void @dec2(i16* nocapture %p) nounwind ssp { 176entry: 177; CHECK-LABEL: dec2: 178; CHECK: decw 179; SLOW_INC-LABEL: dec2: 180; SLOW_INC-NOT: decw 181 %0 = atomicrmw sub i16* %p, i16 1 monotonic 182 ret void 183} 184 185define void @sub6(i16* nocapture %p) nounwind ssp { 186entry: 187; CHECK-LABEL: sub6: 188; CHECK: subw $2 189 %0 = atomicrmw sub i16* %p, i16 2 monotonic 190 ret void 191} 192 193define void @sub2(i16* nocapture %p, i32 %v) nounwind ssp { 194entry: 195; CHECK-LABEL: sub2: 196; CHECK-NOT: negl 197; CHECK: subw 198 %0 = trunc i32 %v to i16 ; <i16> [#uses=1] 199 %1 = atomicrmw sub i16* %p, i16 %0 monotonic 200 ret void 201} 202 203define void @dec1(i32* nocapture %p) nounwind ssp { 204entry: 205; CHECK-LABEL: dec1: 206; CHECK: decl 207; SLOW_INC-LABEL: dec1: 208; SLOW_INC-NOT: decl 209 %0 = atomicrmw sub i32* %p, i32 1 monotonic 210 ret void 211} 212 213define void @sub5(i32* nocapture %p) nounwind ssp { 214entry: 215; CHECK-LABEL: sub5: 216; CHECK: subl $2 217 %0 = atomicrmw sub i32* %p, i32 2 monotonic 218 ret void 219} 220