1 ; Test load-and-trap instructions (LFHAT)
2 ; See comments in asm-18.ll about testing high-word operations.
4 ; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=zEC12 \
5 ; RUN: -no-integrated-as | FileCheck %s
7 declare void @llvm.trap()
9 ; Check LAT with no displacement.
10 define void @f1(ptr %ptr) {
12 ; CHECK: lfhat [[REG:%r[0-9]+]], 0(%r2)
13 ; CHECK: stepa [[REG]]
16 %val = load i32, ptr %ptr
17 %cmp = icmp eq i32 %val, 0
18 br i1 %cmp, label %if.then, label %if.end
20 if.then: ; preds = %entry
21 tail call void @llvm.trap()
24 if.end: ; preds = %entry
25 call void asm sideeffect "stepa $0", "h"(i32 %val)
29 ; Check the high end of the LAT range.
30 define void @f2(ptr %src) {
32 ; CHECK: lfhat [[REG:%r[0-9]+]], 524284(%r2)
33 ; CHECK: stepa [[REG]]
35 %ptr = getelementptr i32, ptr %src, i64 131071
36 %val = load i32, ptr %ptr
37 %cmp = icmp eq i32 %val, 0
38 br i1 %cmp, label %if.then, label %if.end
40 if.then: ; preds = %entry
41 tail call void @llvm.trap()
44 if.end: ; preds = %entry
45 call void asm sideeffect "stepa $0", "h"(i32 %val)
49 ; Check the next word up, which needs separate address logic.
50 ; Other sequences besides this one would be OK.
51 define void @f3(ptr %src) {
53 ; CHECK: agfi %r2, 524288
54 ; CHECK: lfhat [[REG:%r[0-9]+]], 0(%r2)
55 ; CHECK: stepa [[REG]]
57 %ptr = getelementptr i32, ptr %src, i64 131072
58 %val = load i32, ptr %ptr
59 %cmp = icmp eq i32 %val, 0
60 br i1 %cmp, label %if.then, label %if.end
62 if.then: ; preds = %entry
63 tail call void @llvm.trap()
66 if.end: ; preds = %entry
67 call void asm sideeffect "stepa $0", "h"(i32 %val)
71 ; Check that LAT allows an index.
72 define void @f4(i64 %src, i64 %index) {
74 ; CHECK: lfhat [[REG:%r[0-9]+]], 524287(%r3,%r2)
75 ; CHECK: stepa [[REG]]
77 %add1 = add i64 %src, %index
78 %add2 = add i64 %add1, 524287
79 %ptr = inttoptr i64 %add2 to ptr
80 %val = load i32, ptr %ptr
81 %cmp = icmp eq i32 %val, 0
82 br i1 %cmp, label %if.then, label %if.end
84 if.then: ; preds = %entry
85 tail call void @llvm.trap()
88 if.end: ; preds = %entry
89 call void asm sideeffect "stepa $0", "h"(i32 %val)