3 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z15 -verify-machineinstrs | FileCheck %s
6 define i32 @f1(i32 %limit, i32 %a, i32 %b) {
9 ; CHECK: selrl %r2, %r3, %r4
11 %cond = icmp ult i32 %limit, 42
12 %res = select i1 %cond, i32 %a, i32 %b
17 define i64 @f2(i64 %limit, i64 %a, i64 %b) {
19 ; CHECK: clgfi %r2, 42
20 ; CHECK: selgrl %r2, %r3, %r4
22 %cond = icmp ult i64 %limit, 42
23 %res = select i1 %cond, i64 %a, i64 %b
27 ; Test SELR in a case that could use COMPARE AND BRANCH. We prefer using
29 define i32 @f3(i32 %limit, i32 %a, i32 %b) {
32 ; CHECK: selre %r2, %r3, %r4
34 %cond = icmp eq i32 %limit, 42
35 %res = select i1 %cond, i32 %a, i32 %b
39 ; ...and again for SELGR.
40 define i64 @f4(i64 %limit, i64 %a, i64 %b) {
43 ; CHECK: selgre %r2, %r3, %r4
45 %cond = icmp eq i64 %limit, 42
46 %res = select i1 %cond, i64 %a, i64 %b
50 ; Check that we also get SELR as a result of early if-conversion.
51 define i32 @f5(i32 %limit, i32 %a, i32 %b) {
54 ; CHECK: selrh %r2, %r4, %r3
57 %cond = icmp ult i32 %limit, 42
58 br i1 %cond, label %if.then, label %return
64 %res = phi i32 [ %a, %if.then ], [ %b, %entry ]
68 ; ... and likewise for SELGR.
69 define i64 @f6(i64 %limit, i64 %a, i64 %b) {
71 ; CHECK: clgfi %r2, 41
72 ; CHECK: selgrh %r2, %r4, %r3
75 %cond = icmp ult i64 %limit, 42
76 br i1 %cond, label %if.then, label %return
82 %res = phi i64 [ %a, %if.then ], [ %b, %entry ]
86 ; Check that inverting the condition works as well.
87 define i32 @f7(i32 %limit, i32 %a, i32 %b) {
90 ; CHECK: selrh %r2, %r3, %r4
93 %cond = icmp ult i32 %limit, 42
94 br i1 %cond, label %if.then, label %return
100 %res = phi i32 [ %b, %if.then ], [ %a, %entry ]
104 ; ... and likewise for SELGR.
105 define i64 @f8(i64 %limit, i64 %a, i64 %b) {
107 ; CHECK: clgfi %r2, 41
108 ; CHECK: selgrh %r2, %r3, %r4
111 %cond = icmp ult i64 %limit, 42
112 br i1 %cond, label %if.then, label %return
118 %res = phi i64 [ %b, %if.then ], [ %a, %entry ]