1 ; Test 64-bit comparisons in which the second operand is sign-extended
2 ; from a PC-relative i16.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu | FileCheck %s
6 @g = dso_local global i16 1
7 @h = dso_local global i16 1, align 1, section "foo"
9 ; Check signed comparison.
10 define dso_local i64 @f1(i64 %src1) {
13 ; CHECK-NEXT: blr %r14
16 %val = load i16, ptr@g
17 %src2 = sext i16 %val to i64
18 %cond = icmp slt i64 %src1, %src2
19 br i1 %cond, label %exit, label %mulb
21 %mul = mul i64 %src1, %src1
24 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
28 ; Check unsigned comparison, which cannot use CHRL.
29 define dso_local i64 @f2(i64 %src1) {
34 %val = load i16, ptr@g
35 %src2 = sext i16 %val to i64
36 %cond = icmp ult i64 %src1, %src2
37 br i1 %cond, label %exit, label %mulb
39 %mul = mul i64 %src1, %src1
42 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
47 define dso_local i64 @f3(i64 %src1) {
50 ; CHECK-NEXT: ber %r14
53 %val = load i16, ptr@g
54 %src2 = sext i16 %val to i64
55 %cond = icmp eq i64 %src1, %src2
56 br i1 %cond, label %exit, label %mulb
58 %mul = mul i64 %src1, %src1
61 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
66 define dso_local i64 @f4(i64 %src1) {
69 ; CHECK-NEXT: blhr %r14
72 %val = load i16, ptr@g
73 %src2 = sext i16 %val to i64
74 %cond = icmp ne i64 %src1, %src2
75 br i1 %cond, label %exit, label %mulb
77 %mul = mul i64 %src1, %src1
80 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
84 ; Repeat f1 with an unaligned address.
85 define dso_local i64 @f5(i64 %src1) {
87 ; CHECK: lgrl [[REG:%r[0-5]]], h@GOT
88 ; CHECK: cgh %r2, 0([[REG]])
89 ; CHECK-NEXT: blr %r14
92 %val = load i16, ptr@h, align 1
93 %src2 = sext i16 %val to i64
94 %cond = icmp slt i64 %src1, %src2
95 br i1 %cond, label %exit, label %mulb
97 %mul = mul i64 %src1, %src1
100 %res = phi i64 [ %src1, %entry ], [ %mul, %mulb ]
104 ; Check the comparison can be reversed if that allows CGHRL to be used.
105 define dso_local i64 @f6(i64 %src2) {
107 ; CHECK: cghrl %r2, g
108 ; CHECK-NEXT: bhr %r14
111 %val = load i16, ptr@g
112 %src1 = sext i16 %val to i64
113 %cond = icmp slt i64 %src1, %src2
114 br i1 %cond, label %exit, label %mulb
116 %mul = mul i64 %src2, %src2
119 %res = phi i64 [ %src2, %entry ], [ %mul, %mulb ]