1 ; Test 64-bit comparisons in which the second operand is a PC-relative
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
7 @h = global i64 1, align 4, section "foo"
9 ; Check signed comparisons.
10 define i64 @f1(i64 %src1) {
13 ; CHECK-NEXT: blr %r14
16 %src2 = load i64, i64 *@g
17 %cond = icmp slt i64 %src1, %src2
18 br i1 %cond, label %exit, label %mulb
20 %mul = mul i64 %src1, %src1
23 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
27 ; Check unsigned comparisons.
28 define i64 @f2(i64 %src1) {
31 ; CHECK-NEXT: blr %r14
34 %src2 = load i64, i64 *@g
35 %cond = icmp ult i64 %src1, %src2
36 br i1 %cond, label %exit, label %mulb
38 %mul = mul i64 %src1, %src1
41 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
45 ; Check equality, which can use CRL or CLRL.
46 define i64 @f3(i64 %src1) {
48 ; CHECK: c{{l?}}grl %r2, g
49 ; CHECK-NEXT: ber %r14
52 %src2 = load i64, i64 *@g
53 %cond = icmp eq i64 %src1, %src2
54 br i1 %cond, label %exit, label %mulb
56 %mul = mul i64 %src1, %src1
59 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
63 ; ...likewise inequality.
64 define i64 @f4(i64 %src1) {
66 ; CHECK: c{{l?}}grl %r2, g
67 ; CHECK-NEXT: blhr %r14
70 %src2 = load i64, i64 *@g
71 %cond = icmp ne i64 %src1, %src2
72 br i1 %cond, label %exit, label %mulb
74 %mul = mul i64 %src1, %src1
77 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
81 ; Repeat f1 with an unaligned address.
82 define i64 @f5(i64 %src1) {
84 ; CHECK: larl [[REG:%r[0-5]]], h
85 ; CHECK: cg %r2, 0([[REG]])
86 ; CHECK-NEXT: blr %r14
89 %src2 = load i64, i64 *@h, align 4
90 %cond = icmp slt i64 %src1, %src2
91 br i1 %cond, label %exit, label %mulb
93 %mul = mul i64 %src1, %src1
96 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
100 ; Check the comparison can be reversed if that allows CGRL to be used.
101 define i64 @f6(i64 %src2) {
104 ; CHECK-NEXT: bhr %r14
107 %src1 = load i64, i64 *@g
108 %cond = icmp slt i64 %src1, %src2
109 br i1 %cond, label %exit, label %mulb
111 %mul = mul i64 %src2, %src2
114 %res = phi i64 [ %src2, %entry ], [ %mul, %mulb ]