1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; Make sure that a negative value for the compare-and-swap is zero extended
3 ; from i8/i16 to i32 since it will be compared for equality.
4 ; RUN: llc -mtriple=powerpc64le-linux-gnu -verify-machineinstrs < %s | FileCheck %s
5 ; RUN: llc -mtriple=powerpc64le-linux-gnu -mcpu=pwr7 < %s | FileCheck %s --check-prefix=CHECK-P7
7 @str = private unnamed_addr constant [46 x i8] c"FAILED: __atomic_compare_exchange_n() failed.\00"
8 @str.1 = private unnamed_addr constant [59 x i8] c"FAILED: __atomic_compare_exchange_n() set the wrong value.\00"
9 @str.2 = private unnamed_addr constant [7 x i8] c"PASSED\00"
11 define signext i32 @main() {
17 ; CHECK: ori 4, 3, 33059
19 ; CHECK: .LBB0_1: # %L.entry
20 ; CHECK: lharx 3, 0, 5
22 ; CHECK: bne 0, .LBB0_3
23 ; CHECK: sthcx. 6, 0, 5
24 ; CHECK: bne 0, .LBB0_1
26 ; CHECK: .LBB0_3: # %L.entry
27 ; CHECK: sthcx. 3, 0, 5
28 ; CHECK: .LBB0_4: # %L.entry
29 ; CHECK: cmplwi 3, 33059
32 ; CHECK: cmplwi 3, 234
34 ; CHECK-P7-LABEL: main:
35 ; CHECK-P7: li 3, -32477
38 ; CHECK-P7: sth 3, 46(1)
40 ; CHECK-P7: ori 5, 5, 33059
41 ; CHECK-P7: rlwinm 3, 4, 3, 27, 27
42 ; CHECK-P7: ori 7, 7, 65535
44 ; CHECK-P7: slw 6, 6, 3
45 ; CHECK-P7: slw 8, 5, 3
46 ; CHECK-P7: slw 5, 7, 3
47 ; CHECK-P7: rldicr 4, 4, 0, 61
48 ; CHECK-P7: and 7, 6, 5
49 ; CHECK-P7: and 8, 8, 5
50 ; CHECK-P7: .LBB0_1: # %L.entry
51 ; CHECK-P7: lwarx 9, 0, 4
52 ; CHECK-P7: and 6, 9, 5
53 ; CHECK-P7: cmpw 0, 6, 8
54 ; CHECK-P7: bne 0, .LBB0_3
55 ; CHECK-P7: andc 9, 9, 5
56 ; CHECK-P7: or 9, 9, 7
57 ; CHECK-P7: stwcx. 9, 0, 4
58 ; CHECK-P7: bne 0, .LBB0_1
60 ; CHECK-P7: .LBB0_3: # %L.entry
61 ; CHECK-P7: stwcx. 9, 0, 4
62 ; CHECK-P7: .LBB0_4: # %L.entry
63 ; CHECK-P7: srw 3, 6, 3
65 ; CHECK-P7: cmplwi 3, 33059
66 ; CHECK-P7: lhz 3, 46(1)
67 ; CHECK-P7: cmplwi 3, 234
69 %value.addr = alloca i16, align 2
70 store i16 -32477, i16* %value.addr, align 2
71 %0 = cmpxchg i16* %value.addr, i16 -32477, i16 234 seq_cst seq_cst
72 %1 = extractvalue { i16, i1 } %0, 1
73 br i1 %1, label %L.B0000, label %L.B0003
75 L.B0003: ; preds = %L.entry
76 %puts = call i32 @puts(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
79 L.B0000: ; preds = %L.entry
80 %2 = load i16, i16* %value.addr, align 2
81 %3 = icmp eq i16 %2, 234
82 br i1 %3, label %L.B0001, label %L.B0005
84 L.B0005: ; preds = %L.B0000
85 %puts1 = call i32 @puts(i8* getelementptr inbounds ([59 x i8], [59 x i8]* @str.1, i64 0, i64 0))
88 L.B0001: ; preds = %L.B0000
89 %puts2 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.2, i64 0, i64 0))
93 ; Function Attrs: nounwind
94 declare i32 @puts(i8* nocapture readonly) #0