• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; Test strict conversion of floating-point values to unsigned i64s (z10 only).
3;
4; RUN: llc < %s -mtriple=s390x-linux-gnu -mcpu=z10 | FileCheck %s
5
6; z10 doesn't have native support for unsigned fp-to-i64 conversions;
7; they were added in z196 as the Convert to Logical family of instructions.
8; Convert via signed i64s instead.
9; Note that the strict expansion sequence must be used.
10
11declare i64 @llvm.experimental.constrained.fptoui.i64.f32(float, metadata)
12declare i64 @llvm.experimental.constrained.fptoui.i64.f64(double, metadata)
13declare i64 @llvm.experimental.constrained.fptoui.i64.f128(fp128, metadata)
14
15; Test f32->i64.
16define i64 @f1(float %f) #0 {
17; CHECK-LABEL: f1:
18; CHECK:       # %bb.0:
19; CHECK-NEXT:    larl %r1, .LCPI0_0
20; CHECK-NEXT:    le %f1, 0(%r1)
21; CHECK-NEXT:    kebr %f0, %f1
22; CHECK-NEXT:    jnl .LBB0_2
23; CHECK-NEXT:  # %bb.1:
24; CHECK-NEXT:    lghi %r0, 0
25; CHECK-NEXT:    lzer %f1
26; CHECK-NEXT:    j .LBB0_3
27; CHECK-NEXT:  .LBB0_2:
28; CHECK-NEXT:    llihh %r0, 32768
29; CHECK-NEXT:  .LBB0_3:
30; CHECK-NEXT:    sebr %f0, %f1
31; CHECK-NEXT:    cgebr %r2, 5, %f0
32; CHECK-NEXT:    xgr %r2, %r0
33; CHECK-NEXT:    br %r14
34  %conv = call i64 @llvm.experimental.constrained.fptoui.i64.f32(float %f,
35                                               metadata !"fpexcept.strict") #0
36  ret i64 %conv
37}
38
39; Test f64->i64.
40define i64 @f2(double %f) #0 {
41; CHECK-LABEL: f2:
42; CHECK:       # %bb.0:
43; CHECK-NEXT:    larl %r1, .LCPI1_0
44; CHECK-NEXT:    ldeb %f1, 0(%r1)
45; CHECK-NEXT:    kdbr %f0, %f1
46; CHECK-NEXT:    jnl .LBB1_2
47; CHECK-NEXT:  # %bb.1:
48; CHECK-NEXT:    lghi %r0, 0
49; CHECK-NEXT:    lzdr %f1
50; CHECK-NEXT:    j .LBB1_3
51; CHECK-NEXT:  .LBB1_2:
52; CHECK-NEXT:    llihh %r0, 32768
53; CHECK-NEXT:  .LBB1_3:
54; CHECK-NEXT:    sdbr %f0, %f1
55; CHECK-NEXT:    cgdbr %r2, 5, %f0
56; CHECK-NEXT:    xgr %r2, %r0
57; CHECK-NEXT:    br %r14
58  %conv = call i64 @llvm.experimental.constrained.fptoui.i64.f64(double %f,
59                                               metadata !"fpexcept.strict") #0
60  ret i64 %conv
61}
62
63; Test f128->i64.
64define i64 @f3(fp128 *%src) #0 {
65; CHECK-LABEL: f3:
66; CHECK:       # %bb.0:
67; CHECK-NEXT:    ld %f0, 0(%r2)
68; CHECK-NEXT:    ld %f2, 8(%r2)
69; CHECK-NEXT:    larl %r1, .LCPI2_0
70; CHECK-NEXT:    lxeb %f1, 0(%r1)
71; CHECK-NEXT:    kxbr %f0, %f1
72; CHECK-NEXT:    jnl .LBB2_2
73; CHECK-NEXT:  # %bb.1:
74; CHECK-NEXT:    lghi %r0, 0
75; CHECK-NEXT:    lzxr %f1
76; CHECK-NEXT:    j .LBB2_3
77; CHECK-NEXT:  .LBB2_2:
78; CHECK-NEXT:    llihh %r0, 32768
79; CHECK-NEXT:  .LBB2_3:
80; CHECK-NEXT:    sxbr %f0, %f1
81; CHECK-NEXT:    cgxbr %r2, 5, %f0
82; CHECK-NEXT:    xgr %r2, %r0
83; CHECK-NEXT:    br %r14
84  %f = load fp128, fp128 *%src
85  %conv = call i64 @llvm.experimental.constrained.fptoui.i64.f128(fp128 %f,
86                                               metadata !"fpexcept.strict") #0
87  ret i64 %conv
88}
89
90attributes #0 = { strictfp }
91