1 ; Test 32-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 i32 @f1(i32 %src1) {
13 ; CHECK-NEXT: blr %r14
16 %val = load i16, ptr@g
17 %src2 = sext i16 %val to i32
18 %cond = icmp slt i32 %src1, %src2
19 br i1 %cond, label %exit, label %mulb
21 %mul = mul i32 %src1, %src1
24 %res = phi i32 [ %src1, %entry ], [ %mul, %mulb ]
28 ; Check unsigned comparison, which cannot use CHRL.
29 define dso_local i32 @f2(i32 %src1) {
34 %val = load i16, ptr@g
35 %src2 = sext i16 %val to i32
36 %cond = icmp ult i32 %src1, %src2
37 br i1 %cond, label %exit, label %mulb
39 %mul = mul i32 %src1, %src1
42 %res = phi i32 [ %src1, %entry ], [ %mul, %mulb ]
47 define dso_local i32 @f3(i32 %src1) {
50 ; CHECK-NEXT: ber %r14
53 %val = load i16, ptr@g
54 %src2 = sext i16 %val to i32
55 %cond = icmp eq i32 %src1, %src2
56 br i1 %cond, label %exit, label %mulb
58 %mul = mul i32 %src1, %src1
61 %res = phi i32 [ %src1, %entry ], [ %mul, %mulb ]
66 define dso_local i32 @f4(i32 %src1) {
69 ; CHECK-NEXT: blhr %r14
72 %val = load i16, ptr@g
73 %src2 = sext i16 %val to i32
74 %cond = icmp ne i32 %src1, %src2
75 br i1 %cond, label %exit, label %mulb
77 %mul = mul i32 %src1, %src1
80 %res = phi i32 [ %src1, %entry ], [ %mul, %mulb ]
84 ; Repeat f1 with an unaligned address.
85 define dso_local i32 @f5(i32 %src1) {
87 ; CHECK: lgrl [[REG:%r[0-5]]], h@GOT
88 ; CHECK: ch %r2, 0([[REG]])
89 ; CHECK-NEXT: blr %r14
92 %val = load i16, ptr@h, align 1
93 %src2 = sext i16 %val to i32
94 %cond = icmp slt i32 %src1, %src2
95 br i1 %cond, label %exit, label %mulb
97 %mul = mul i32 %src1, %src1
100 %res = phi i32 [ %src1, %entry ], [ %mul, %mulb ]
104 ; Check the comparison can be reversed if that allows CHRL to be used.
105 define dso_local i32 @f6(i32 %src2) {
108 ; CHECK-NEXT: bhr %r14
111 %val = load i16, ptr@g
112 %src1 = sext i16 %val to i32
113 %cond = icmp slt i32 %src1, %src2
114 br i1 %cond, label %exit, label %mulb
116 %mul = mul i32 %src2, %src2
119 %res = phi i32 [ %src2, %entry ], [ %mul, %mulb ]