1 ; RUN: opt < %s -loweratomic -S | FileCheck %s 2 3 define i8 @cmpswap() { 4 ; CHECK-LABEL: @cmpswap( 5 %i = alloca i8 6 %pair = cmpxchg i8* %i, i8 0, i8 42 monotonic monotonic 7 %j = extractvalue { i8, i1 } %pair, 0 8 ; CHECK: [[OLDVAL:%[a-z0-9]+]] = load i8* [[ADDR:%[a-z0-9]+]] 9 ; CHECK-NEXT: [[SAME:%[a-z0-9]+]] = icmp eq i8 [[OLDVAL]], 0 10 ; CHECK-NEXT: [[TO_STORE:%[a-z0-9]+]] = select i1 [[SAME]], i8 42, i8 [[OLDVAL]] 11 ; CHECK-NEXT: store i8 [[TO_STORE]], i8* [[ADDR]] 12 ; CHECK-NEXT: [[TMP:%[a-z0-9]+]] = insertvalue { i8, i1 } undef, i8 [[OLDVAL]], 0 13 ; CHECK-NEXT: [[RES:%[a-z0-9]+]] = insertvalue { i8, i1 } [[TMP]], i1 [[SAME]], 1 14 ; CHECK-NEXT: [[VAL:%[a-z0-9]+]] = extractvalue { i8, i1 } [[RES]], 0 15 ret i8 %j 16 ; CHECK: ret i8 [[VAL]] 17 } 18 19 20 define i8 @swap() { 21 ; CHECK-LABEL: @swap( 22 %i = alloca i8 23 %j = atomicrmw xchg i8* %i, i8 42 monotonic 24 ; CHECK: [[INST:%[a-z0-9]+]] = load 25 ; CHECK-NEXT: store 26 ret i8 %j 27 ; CHECK: ret i8 [[INST]] 28 } 29