[SystemZ] Prefer comparisons with zero

Convert >= 1 to > 0, etc.  Using comparison with zero isn't a win on its own,
but it exposes more opportunities for CC reuse (the next patch).

llvm-svn: 187571
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-09.ll b/llvm/test/CodeGen/SystemZ/int-cmp-09.ll
index 66c9d8d..0eb8c66 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-09.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-09.ll
@@ -13,13 +13,13 @@
   ret double %res
 }
 
-; Check comparisons with 1.
+; Check comparisons with 2.
 define double @f2(double %a, double %b, i32 %i1) {
 ; CHECK-LABEL: f2:
-; CHECK: cijl %r2, 1
+; CHECK: cijl %r2, 2
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
-  %cond = icmp slt i32 %i1, 1
+  %cond = icmp slt i32 %i1, 2
   %res = select i1 %cond, double %a, double %b
   ret double %res
 }
@@ -176,3 +176,47 @@
   %res = select i1 %cond, double %a, double %b
   ret double %res
 }
+
+; Check that < 1 becomes <= 0.
+define double @f16(double %a, double %b, i32 %i1) {
+; CHECK-LABEL: f16:
+; CHECK: cijle %r2, 0
+; CHECK: ldr %f0, %f2
+; CHECK: br %r14
+  %cond = icmp slt i32 %i1, 1
+  %res = select i1 %cond, double %a, double %b
+  ret double %res
+}
+
+; Check that >= 1 becomes > 0.
+define double @f17(double %a, double %b, i32 %i1) {
+; CHECK-LABEL: f17:
+; CHECK: cijh %r2, 0
+; CHECK: ldr %f0, %f2
+; CHECK: br %r14
+  %cond = icmp sge i32 %i1, 1
+  %res = select i1 %cond, double %a, double %b
+  ret double %res
+}
+
+; Check that > -1 becomes >= 0.
+define double @f18(double %a, double %b, i32 %i1) {
+; CHECK-LABEL: f18:
+; CHECK: cijhe %r2, 0
+; CHECK: ldr %f0, %f2
+; CHECK: br %r14
+  %cond = icmp sgt i32 %i1, -1
+  %res = select i1 %cond, double %a, double %b
+  ret double %res
+}
+
+; Check that <= -1 becomes < 0.
+define double @f19(double %a, double %b, i32 %i1) {
+; CHECK-LABEL: f19:
+; CHECK: cijl %r2, 0
+; CHECK: ldr %f0, %f2
+; CHECK: br %r14
+  %cond = icmp sle i32 %i1, -1
+  %res = select i1 %cond, double %a, double %b
+  ret double %res
+}
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-11.ll b/llvm/test/CodeGen/SystemZ/int-cmp-11.ll
index 8dd2ebc..c74135a 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-11.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-11.ll
@@ -16,7 +16,7 @@
 ; Check comparisons with 1.
 define double @f2(double %a, double %b, i64 %i1) {
 ; CHECK-LABEL: f2:
-; CHECK: cgijl %r2, 1
+; CHECK: cgijle %r2, 0
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp slt i64 %i1, 1
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-22.ll b/llvm/test/CodeGen/SystemZ/int-cmp-22.ll
index ea16604..43daec9 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-22.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-22.ll
@@ -18,8 +18,8 @@
 ; Check comparisons with 1.
 define double @f2(double %a, double %b, i16 *%ptr) {
 ; CHECK-LABEL: f2:
-; CHECK: chhsi 0(%r2), 1
-; CHECK-NEXT: jl
+; CHECK: chhsi 0(%r2), 0
+; CHECK-NEXT: jle
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %val = load i16 *%ptr
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-32.ll b/llvm/test/CodeGen/SystemZ/int-cmp-32.ll
index 96398dd..6596f9f 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-32.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-32.ll
@@ -18,8 +18,8 @@
 ; Check ordered comparisons with 1.
 define double @f2(double %a, double %b, i32 *%ptr) {
 ; CHECK-LABEL: f2:
-; CHECK: chsi 0(%r2), 1
-; CHECK-NEXT: jl
+; CHECK: chsi 0(%r2), 0
+; CHECK-NEXT: jle
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %val = load i32 *%ptr
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-34.ll b/llvm/test/CodeGen/SystemZ/int-cmp-34.ll
index 53a5c76..8a02197 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-34.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-34.ll
@@ -18,8 +18,8 @@
 ; Check ordered comparisons with 1.
 define double @f2(double %a, double %b, i64 *%ptr) {
 ; CHECK-LABEL: f2:
-; CHECK: cghsi 0(%r2), 1
-; CHECK-NEXT: jl
+; CHECK: cghsi 0(%r2), 0
+; CHECK-NEXT: jle
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %val = load i64 *%ptr