summaryrefslogtreecommitdiff
path: root/test/CodeGen/SystemZ
diff options
context:
space:
mode:
authorUlrich Weigand <ulrich.weigand@de.ibm.com>2017-09-28 16:22:54 +0000
committerUlrich Weigand <ulrich.weigand@de.ibm.com>2017-09-28 16:22:54 +0000
commite7870d75ef7b9b6c844b38f37ecf931ca39e394c (patch)
treea9f038bf4ebbf60d4895f2dddad96d8b439f152f /test/CodeGen/SystemZ
parent6bae1b9b2b8ac34fb81415e1fd8824574acf3765 (diff)
[SystemZ] Custom-expand ATOMIC_CMP_AND_SWAP_WITH_SUCCESS
The SystemZ compare-and-swap instructions already provide the "success" indication via a condition-code value, so the default expansion of those operations generates an unnecessary extra comparsion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@314428 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen/SystemZ')
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-01.ll33
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-02.ll33
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-03.ll14
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-04.ll15
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-05.ll25
-rw-r--r--test/CodeGen/SystemZ/cmpxchg-06.ll18
6 files changed, 113 insertions, 25 deletions
diff --git a/test/CodeGen/SystemZ/cmpxchg-01.ll b/test/CodeGen/SystemZ/cmpxchg-01.ll
index a74c2ff878e..8257a36ddde 100644
--- a/test/CodeGen/SystemZ/cmpxchg-01.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-01.ll
@@ -55,3 +55,36 @@ define i8 @f2(i8 *%src) {
%res = extractvalue { i8, i1 } %pair, 0
ret i8 %res
}
+
+; Check generating the comparison result.
+define i32 @f3(i8 %dummy, i8 *%src, i8 %cmp, i8 %swap) {
+; CHECK-MAIN-LABEL: f3:
+; CHECK-MAIN: risbg [[RISBG:%r[1-9]+]], %r3, 0, 189, 0{{$}}
+; CHECK-MAIN: sll %r3, 3
+; CHECK-MAIN: l [[OLD:%r[0-9]+]], 0([[RISBG]])
+; CHECK-MAIN: [[LOOP:\.[^ ]*]]:
+; CHECK-MAIN: rll [[TMP:%r[0-9]+]], [[OLD]], 8(%r3)
+; CHECK-MAIN: risbg %r4, [[TMP]], 32, 55, 0
+; CHECK-MAIN: crjlh [[TMP]], %r4, [[EXIT:\.[^ ]*]]
+; CHECK-MAIN: risbg %r5, [[TMP]], 32, 55, 0
+; CHECK-MAIN: rll [[NEW:%r[0-9]+]], %r5, -8({{%r[1-9]+}})
+; CHECK-MAIN: cs [[OLD]], [[NEW]], 0([[RISBG]])
+; CHECK-MAIN: jl [[LOOP]]
+; CHECK-MAIN: [[EXIT]]:
+; CHECK-MAIN-NEXT: ipm %r2
+; CHECK-MAIN-NEXT: afi %r2, -268435456
+; CHECK-MAIN-NEXT: srl %r2, 31
+; CHECK-MAIN-NOT: %r2
+; CHECK-MAIN: br %r14
+;
+; CHECK-SHIFT-LABEL: f3:
+; CHECK-SHIFT: sll [[SHIFT:%r[1-9]+]], 3
+; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], [[SHIFT]]
+; CHECK-SHIFT: rll
+; CHECK-SHIFT: rll {{%r[0-9]+}}, %r5, -8([[NEGSHIFT]])
+ %pair = cmpxchg i8 *%src, i8 %cmp, i8 %swap seq_cst seq_cst
+ %val = extractvalue { i8, i1 } %pair, 1
+ %res = zext i1 %val to i32
+ ret i32 %res
+}
+
diff --git a/test/CodeGen/SystemZ/cmpxchg-02.ll b/test/CodeGen/SystemZ/cmpxchg-02.ll
index 2445c0deab1..48e1e18db9b 100644
--- a/test/CodeGen/SystemZ/cmpxchg-02.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-02.ll
@@ -55,3 +55,36 @@ define i16 @f2(i16 *%src) {
%res = extractvalue { i16, i1 } %pair, 0
ret i16 %res
}
+
+; Check generating the comparison result.
+define i32 @f3(i16 %dummy, i16 *%src, i16 %cmp, i16 %swap) {
+; CHECK-MAIN-LABEL: f3:
+; CHECK-MAIN: risbg [[RISBG:%r[1-9]+]], %r3, 0, 189, 0{{$}}
+; CHECK-MAIN: sll %r3, 3
+; CHECK-MAIN: l [[OLD:%r[0-9]+]], 0([[RISBG]])
+; CHECK-MAIN: [[LOOP:\.[^ ]*]]:
+; CHECK-MAIN: rll [[TMP:%r[0-9]+]], [[OLD]], 16(%r3)
+; CHECK-MAIN: risbg %r4, [[TMP]], 32, 47, 0
+; CHECK-MAIN: crjlh [[TMP]], %r4, [[EXIT:\.[^ ]*]]
+; CHECK-MAIN: risbg %r5, [[TMP]], 32, 47, 0
+; CHECK-MAIN: rll [[NEW:%r[0-9]+]], %r5, -16({{%r[1-9]+}})
+; CHECK-MAIN: cs [[OLD]], [[NEW]], 0([[RISBG]])
+; CHECK-MAIN: jl [[LOOP]]
+; CHECK-MAIN: [[EXIT]]:
+; CHECK-MAIN-NEXT: ipm %r2
+; CHECK-MAIN-NEXT: afi %r2, -268435456
+; CHECK-MAIN-NEXT: srl %r2, 31
+; CHECK-MAIN-NOT: %r2
+; CHECK-MAIN: br %r14
+;
+; CHECK-SHIFT-LABEL: f3:
+; CHECK-SHIFT: sll %r3, 3
+; CHECK-SHIFT: lcr [[NEGSHIFT:%r[1-9]+]], %r3
+; CHECK-SHIFT: rll
+; CHECK-SHIFT: rll {{%r[0-9]+}}, %r5, -16([[NEGSHIFT]])
+ %pair = cmpxchg i16 *%src, i16 %cmp, i16 %swap seq_cst seq_cst
+ %val = extractvalue { i16, i1 } %pair, 1
+ %res = zext i1 %val to i32
+ ret i32 %res
+}
+
diff --git a/test/CodeGen/SystemZ/cmpxchg-03.ll b/test/CodeGen/SystemZ/cmpxchg-03.ll
index c6e1955a50f..d2576e4291b 100644
--- a/test/CodeGen/SystemZ/cmpxchg-03.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-03.ll
@@ -141,3 +141,17 @@ define i32 @f12(i32 %cmp, i32 *%ptr) {
%val = extractvalue { i32, i1 } %pair, 0
ret i32 %val
}
+
+; Check generating the comparison result.
+; CHECK-LABEL: f13
+; CHECK: cs %r2, %r3, 0(%r4)
+; CHECK-NEXT: ipm %r2
+; CHECK-NEXT: afi %r2, -268435456
+; CHECK-NEXT: srl %r2, 31
+; CHECK: br %r14
+define i32 @f13(i32 %cmp, i32 %swap, i32 *%src) {
+ %pairval = cmpxchg i32 *%src, i32 %cmp, i32 %swap seq_cst seq_cst
+ %val = extractvalue { i32, i1 } %pairval, 1
+ %res = zext i1 %val to i32
+ ret i32 %res
+}
diff --git a/test/CodeGen/SystemZ/cmpxchg-04.ll b/test/CodeGen/SystemZ/cmpxchg-04.ll
index b0560876b87..f461315b999 100644
--- a/test/CodeGen/SystemZ/cmpxchg-04.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-04.ll
@@ -105,3 +105,18 @@ define i64 @f9(i64 %cmp, i64 *%ptr) {
%val = extractvalue { i64, i1 } %pairval, 0
ret i64 %val
}
+
+; Check generating the comparison result.
+; CHECK-LABEL: f10
+; CHECK: csg %r2, %r3, 0(%r4)
+; CHECK-NEXT: ipm %r2
+; CHECK-NEXT: afi %r2, -268435456
+; CHECK-NEXT: srl %r2, 31
+; CHECK: br %r14
+define i32 @f10(i64 %cmp, i64 %swap, i64 *%src) {
+ %pairval = cmpxchg i64 *%src, i64 %cmp, i64 %swap seq_cst seq_cst
+ %val = extractvalue { i64, i1 } %pairval, 1
+ %res = zext i1 %val to i32
+ ret i32 %res
+}
+
diff --git a/test/CodeGen/SystemZ/cmpxchg-05.ll b/test/CodeGen/SystemZ/cmpxchg-05.ll
index 68261efa638..ecfe2dabeaf 100644
--- a/test/CodeGen/SystemZ/cmpxchg-05.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-05.ll
@@ -54,28 +54,3 @@ define signext i16 @f4(i16* nocapture, i16 signext, i16 signext) {
ret i16 %res
}
-; Now use the comparison result.
-; CHECK-LABEL: f5
-; CHECK: llcr [[REG:%r[0-9]+]], [[RES:%r[0-9]+]]
-; CHECK: cr [[REG]], %r3
-define zeroext i8 @f5(i8* nocapture, i8 zeroext, i8 zeroext) {
- %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
- %res = extractvalue { i8, i1 } %cx, 1
- %xres = sext i1 %res to i8
- ret i8 %xres
-}
-
-; Now use the comparison result and zero-extended old value.
-; CHECK-LABEL: f6
-; CHECK: llcr [[REG:%r[0-9]+]], [[RES:%r[0-9]+]]
-; CHECK: st [[REG]], 0(%r5)
-; CHECK: cr [[REG]], %r3
-define zeroext i8 @f6(i8* nocapture, i8 zeroext, i8 zeroext, i32*) {
- %cx = cmpxchg i8* %0, i8 %1, i8 %2 seq_cst seq_cst
- %old = extractvalue { i8, i1 } %cx, 0
- %xold = zext i8 %old to i32
- store i32 %xold, i32* %3
- %res = extractvalue { i8, i1 } %cx, 1
- %xres = sext i1 %res to i8
- ret i8 %xres
-}
diff --git a/test/CodeGen/SystemZ/cmpxchg-06.ll b/test/CodeGen/SystemZ/cmpxchg-06.ll
index da565791c7c..7da2ea0fde8 100644
--- a/test/CodeGen/SystemZ/cmpxchg-06.ll
+++ b/test/CodeGen/SystemZ/cmpxchg-06.ll
@@ -111,3 +111,21 @@ define i128 @f9(i128 %cmp, i128 *%ptr) {
%val = extractvalue { i128, i1 } %pairval, 0
ret i128 %val
}
+
+; Check generating the comparison result.
+; CHECK-LABEL: f10
+; CHECK-DAG: lg %r1, 8(%r3)
+; CHECK-DAG: lg %r0, 0(%r3)
+; CHECK-DAG: lg %r13, 8(%r2)
+; CHECK-DAG: lg %r12, 0(%r2)
+; CHECK: cdsg %r12, %r0, 0(%r4)
+; CHECK-NEXT: ipm %r2
+; CHECK-NEXT: afi %r2, -268435456
+; CHECK-NEXT: srl %r2, 31
+; CHECK: br %r14
+define i32 @f10(i128 %cmp, i128 %swap, i128 *%src) {
+ %pairval = cmpxchg i128 *%src, i128 %cmp, i128 %swap seq_cst seq_cst
+ %val = extractvalue { i128, i1 } %pairval, 1
+ %res = zext i1 %val to i32
+ ret i32 %res
+}