• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test load-and-trap instructions (LFHAT)
2; See comments in asm-18.ll about testing high-word operations.
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=zEC12 \
5; RUN:   -no-integrated-as | FileCheck %s
6
7declare void @llvm.trap()
8
9; Check LAT with no displacement.
10define void @f1(i32 *%ptr) {
11; CHECK-LABEL: f1:
12; CHECK: lfhat [[REG:%r[0-9]+]], 0(%r2)
13; CHECK: stepa [[REG]]
14; CHECK: br %r14
15entry:
16  %val = load i32, i32 *%ptr
17  %cmp = icmp eq i32 %val, 0
18  br i1 %cmp, label %if.then, label %if.end
19
20if.then:                                          ; preds = %entry
21  tail call void @llvm.trap()
22  unreachable
23
24if.end:                                           ; preds = %entry
25  call void asm sideeffect "stepa $0", "h"(i32 %val)
26  ret void;
27}
28
29; Check the high end of the LAT range.
30define void @f2(i32 *%src) {
31; CHECK-LABEL: f2:
32; CHECK: lfhat [[REG:%r[0-9]+]], 524284(%r2)
33; CHECK: stepa [[REG]]
34; CHECK: br %r14
35  %ptr = getelementptr i32, i32 *%src, i64 131071
36  %val = load i32, i32 *%ptr
37  %cmp = icmp eq i32 %val, 0
38  br i1 %cmp, label %if.then, label %if.end
39
40if.then:                                          ; preds = %entry
41  tail call void @llvm.trap()
42  unreachable
43
44if.end:                                           ; preds = %entry
45  call void asm sideeffect "stepa $0", "h"(i32 %val)
46  ret void;
47}
48
49; Check the next word up, which needs separate address logic.
50; Other sequences besides this one would be OK.
51define void @f3(i32 *%src) {
52; CHECK-LABEL: f3:
53; CHECK: agfi %r2, 524288
54; CHECK: lfhat [[REG:%r[0-9]+]], 0(%r2)
55; CHECK: stepa [[REG]]
56; CHECK: br %r14
57  %ptr = getelementptr i32, i32 *%src, i64 131072
58  %val = load i32, i32 *%ptr
59  %cmp = icmp eq i32 %val, 0
60  br i1 %cmp, label %if.then, label %if.end
61
62if.then:                                          ; preds = %entry
63  tail call void @llvm.trap()
64  unreachable
65
66if.end:                                           ; preds = %entry
67  call void asm sideeffect "stepa $0", "h"(i32 %val)
68  ret void;
69}
70
71; Check that LAT allows an index.
72define void @f4(i64 %src, i64 %index) {
73; CHECK-LABEL: f4:
74; CHECK: lfhat [[REG:%r[0-9]+]], 524287(%r3,%r2)
75; CHECK: stepa [[REG]]
76; CHECK: br %r14
77  %add1 = add i64 %src, %index
78  %add2 = add i64 %add1, 524287
79  %ptr = inttoptr i64 %add2 to i32 *
80  %val = load i32, i32 *%ptr
81  %cmp = icmp eq i32 %val, 0
82  br i1 %cmp, label %if.then, label %if.end
83
84if.then:                                          ; preds = %entry
85  tail call void @llvm.trap()
86  unreachable
87
88if.end:                                           ; preds = %entry
89  call void asm sideeffect "stepa $0", "h"(i32 %val)
90  ret void;
91}
92
93