summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/SystemZ/int-neg-02.ll
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-12-13 15:35:00 +0000
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-12-13 15:35:00 +0000
commit57485472e29cf063c765d231c65c0be4f075e299 (patch)
tree971a37e667baf1e38cde85330b390002355b5f85 /llvm/test/CodeGen/SystemZ/int-neg-02.ll
parentd420f7344fed3ee18d386cd57dc0608675aa55d9 (diff)
downloadbcm5719-llvm-57485472e29cf063c765d231c65c0be4f075e299.tar.gz
bcm5719-llvm-57485472e29cf063c765d231c65c0be4f075e299.zip
[SystemZ] Extend integer absolute selection
This patch makes more use of LPGFR and LNGFR. It builds on top of the LTGFR selection from r197234. Most of the tests are motivated by what InstCombine would produce. llvm-svn: 197236
Diffstat (limited to 'llvm/test/CodeGen/SystemZ/int-neg-02.ll')
-rw-r--r--llvm/test/CodeGen/SystemZ/int-neg-02.ll133
1 files changed, 133 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/SystemZ/int-neg-02.ll b/llvm/test/CodeGen/SystemZ/int-neg-02.ll
index e26194c162d..7f3f6375129 100644
--- a/llvm/test/CodeGen/SystemZ/int-neg-02.ll
+++ b/llvm/test/CodeGen/SystemZ/int-neg-02.ll
@@ -89,3 +89,136 @@ define i64 @f7(i64 %val) {
%res = sub i64 0, %abs
ret i64 %res
}
+
+; Test another form of f6, which is that produced by InstCombine.
+define i64 @f8(i64 %val) {
+; CHECK-LABEL: f8:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp slt i64 %shl, 0
+ %abs = select i1 %cmp, i64 %neg, i64 %ashr
+ %res = sub i64 0, %abs
+ ret i64 %res
+}
+
+; Try again with sle rather than slt.
+define i64 @f9(i64 %val) {
+; CHECK-LABEL: f9:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sle i64 %shl, 0
+ %abs = select i1 %cmp, i64 %neg, i64 %ashr
+ %res = sub i64 0, %abs
+ ret i64 %res
+}
+
+; Repeat f8 with the operands reversed.
+define i64 @f10(i64 %val) {
+; CHECK-LABEL: f10:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sgt i64 %shl, 0
+ %abs = select i1 %cmp, i64 %ashr, i64 %neg
+ %res = sub i64 0, %abs
+ ret i64 %res
+}
+
+; Try again with sge rather than sgt.
+define i64 @f11(i64 %val) {
+; CHECK-LABEL: f11:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sge i64 %shl, 0
+ %abs = select i1 %cmp, i64 %ashr, i64 %neg
+ %res = sub i64 0, %abs
+ ret i64 %res
+}
+
+; Repeat f8 with the negation coming from swapped operands.
+define i64 @f12(i64 %val) {
+; CHECK-LABEL: f12:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp slt i64 %shl, 0
+ %negabs = select i1 %cmp, i64 %ashr, i64 %neg
+ ret i64 %negabs
+}
+
+; Likewise f9.
+define i64 @f13(i64 %val) {
+; CHECK-LABEL: f13:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sle i64 %shl, 0
+ %negabs = select i1 %cmp, i64 %ashr, i64 %neg
+ ret i64 %negabs
+}
+
+; Likewise f10.
+define i64 @f14(i64 %val) {
+; CHECK-LABEL: f14:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sgt i64 %shl, 0
+ %negabs = select i1 %cmp, i64 %neg, i64 %ashr
+ ret i64 %negabs
+}
+
+; Likewise f11.
+define i64 @f15(i64 %val) {
+; CHECK-LABEL: f15:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %shl = shl i64 %val, 32
+ %ashr = ashr i64 %shl, 32
+ %neg = sub i64 0, %ashr
+ %cmp = icmp sge i64 %shl, 0
+ %negabs = select i1 %cmp, i64 %neg, i64 %ashr
+ ret i64 %negabs
+}
+
+; Repeat f5 with the comparison on the unextended value.
+define i64 @f16(i32 %val) {
+; CHECK-LABEL: f16:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %ext = sext i32 %val to i64
+ %cmp = icmp slt i32 %val, 0
+ %neg = sub i64 0, %ext
+ %abs = select i1 %cmp, i64 %neg, i64 %ext
+ %res = sub i64 0, %abs
+ ret i64 %res
+}
+
+; And again with the negation coming from swapped operands.
+define i64 @f17(i32 %val) {
+; CHECK-LABEL: f17:
+; CHECK: lngfr %r2, %r2
+; CHECK: br %r14
+ %ext = sext i32 %val to i64
+ %cmp = icmp slt i32 %val, 0
+ %neg = sub i64 0, %ext
+ %abs = select i1 %cmp, i64 %ext, i64 %neg
+ ret i64 %abs
+}
OpenPOWER on IntegriCloud