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