1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -mtriple=powerpc-apple-darwin -march=ppc32 | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Workerdefine i32 @exchange_and_add(i32* %mem, i32 %val) nounwind { 4*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_add: 5*9880d681SAndroid Build Coastguard Worker; CHECK: lwarx {{r[0-9]+}}, 0, {{r[0-9]+}} 6*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw add i32* %mem, i32 %val monotonic 7*9880d681SAndroid Build Coastguard Worker; CHECK: stwcx. {{r[0-9]+}}, 0, {{r[0-9]+}} 8*9880d681SAndroid Build Coastguard Worker ret i32 %tmp 9*9880d681SAndroid Build Coastguard Worker} 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard Workerdefine i32 @exchange_and_cmp(i32* %mem) nounwind { 12*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange_and_cmp: 13*9880d681SAndroid Build Coastguard Worker; CHECK: lwarx 14*9880d681SAndroid Build Coastguard Worker %tmppair = cmpxchg i32* %mem, i32 0, i32 1 monotonic monotonic 15*9880d681SAndroid Build Coastguard Worker %tmp = extractvalue { i32, i1 } %tmppair, 0 16*9880d681SAndroid Build Coastguard Worker; CHECK: stwcx. 17*9880d681SAndroid Build Coastguard Worker; CHECK: stwcx. 18*9880d681SAndroid Build Coastguard Worker ret i32 %tmp 19*9880d681SAndroid Build Coastguard Worker} 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Workerdefine i32 @exchange(i32* %mem, i32 %val) nounwind { 22*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: exchange: 23*9880d681SAndroid Build Coastguard Worker; CHECK: lwarx 24*9880d681SAndroid Build Coastguard Worker %tmp = atomicrmw xchg i32* %mem, i32 1 monotonic 25*9880d681SAndroid Build Coastguard Worker; CHECK: stwcx. 26*9880d681SAndroid Build Coastguard Worker ret i32 %tmp 27*9880d681SAndroid Build Coastguard Worker} 28