[SystemZ] Implement conditional returns

Return is now considered a predicable instruction, and is converted
to a newly-added CondReturn (which maps to BCR to %r14) instruction by
the if conversion pass.

Also, fused compare-and-branch transform knows about conditional
returns, emitting the proper fused instructions for them.

This transform triggers on a *lot* of tests, hence the huge diffstat.
The changes are mostly jX to br %r14 -> bXr %r14.

Author: koriakin

Differential Revision: http://reviews.llvm.org/D17339

llvm-svn: 265689
diff --git a/llvm/test/CodeGen/SystemZ/int-cmp-14.ll b/llvm/test/CodeGen/SystemZ/int-cmp-14.ll
index 4dbd0ec..d63aaa3 100644
--- a/llvm/test/CodeGen/SystemZ/int-cmp-14.ll
+++ b/llvm/test/CodeGen/SystemZ/int-cmp-14.ll
@@ -9,7 +9,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 0
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -20,7 +21,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 127
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -32,7 +34,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 128
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -44,7 +47,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 32767
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -56,7 +60,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 32768
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -68,7 +73,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 2147483647
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -80,7 +86,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 2147483648
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -92,7 +99,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 4294967295
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -103,7 +111,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, 4294967296
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -114,7 +123,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -1
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -125,7 +135,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -128
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -137,7 +148,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -129
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -149,7 +161,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -32768
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -161,7 +174,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -32769
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -173,7 +187,8 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -2147483648
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }
 
@@ -184,6 +199,7 @@
 ; CHECK: ldr %f0, %f2
 ; CHECK: br %r14
   %cond = icmp ne i64 %i1, -2147483649
-  %res = select i1 %cond, double %a, double %b
+  %tmp = select i1 %cond, double %a, double %b
+  %res = fadd double %tmp, 1.0
   ret double %res
 }