xref: /llvm-project/llvm/test/CodeGen/SPARC/float-constants.ll (revision 728490257ecc09ada707a0390303bd3c61027a53)
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2; RUN: llc < %s -mtriple=sparc | FileCheck %s
3; RUN: llc < %s -mtriple=sparcel | FileCheck %s --check-prefix=CHECK-LE
4
5;; Bitcast should not do a runtime conversion, but rather emit a
6;; constant into integer registers directly.
7
8define <2 x i32> @bitcast() nounwind {
9; CHECK-LABEL: bitcast:
10; CHECK:       ! %bb.0:
11; CHECK-NEXT:    sethi 1049856, %o0
12; CHECK-NEXT:    retl
13; CHECK-NEXT:    mov %g0, %o1
14;
15; CHECK-LE-LABEL: bitcast:
16; CHECK-LE:       ! %bb.0:
17; CHECK-LE-NEXT:    sethi 1049856, %o1
18; CHECK-LE-NEXT:    retl
19; CHECK-LE-NEXT:    mov %g0, %o0
20  %1 = bitcast double 5.0 to <2 x i32>
21  ret <2 x i32> %1
22}
23
24;; Same thing for a call using a double (which gets passed in integer
25;; registers)
26
27declare void @a(double)
28define void @test_call() nounwind {
29; CHECK-LABEL: test_call:
30; CHECK:       ! %bb.0:
31; CHECK-NEXT:    save %sp, -96, %sp
32; CHECK-NEXT:    sethi 1049856, %o0
33; CHECK-NEXT:    call a
34; CHECK-NEXT:    mov %g0, %o1
35; CHECK-NEXT:    ret
36; CHECK-NEXT:    restore
37;
38; CHECK-LE-LABEL: test_call:
39; CHECK-LE:       ! %bb.0:
40; CHECK-LE-NEXT:    save %sp, -96, %sp
41; CHECK-LE-NEXT:    sethi 1049856, %o1
42; CHECK-LE-NEXT:    call a
43; CHECK-LE-NEXT:    mov %g0, %o0
44; CHECK-LE-NEXT:    ret
45; CHECK-LE-NEXT:    restore
46  call void @a(double 5.0)
47  ret void
48}
49
50;; And for a libcall emitted from the pow intrinsic.  (libcall
51;; emission happens after SelectionDAG type legalization, so is a bit
52;; different than a normal function call. This was crashing before,
53;; due to an earlier broken workaround for this issue.)
54
55declare double @llvm.pow.f64(double, double)
56define double @test_intrins_call() nounwind {
57; CHECK-LABEL: test_intrins_call:
58; CHECK:       ! %bb.0:
59; CHECK-NEXT:    save %sp, -96, %sp
60; CHECK-NEXT:    sethi 1048576, %o0
61; CHECK-NEXT:    mov %g0, %o1
62; CHECK-NEXT:    mov %o0, %o2
63; CHECK-NEXT:    call pow
64; CHECK-NEXT:    mov %g0, %o3
65; CHECK-NEXT:    ret
66; CHECK-NEXT:    restore
67;
68; CHECK-LE-LABEL: test_intrins_call:
69; CHECK-LE:       ! %bb.0:
70; CHECK-LE-NEXT:    save %sp, -96, %sp
71; CHECK-LE-NEXT:    sethi 1048576, %o1
72; CHECK-LE-NEXT:    mov %g0, %o0
73; CHECK-LE-NEXT:    mov %g0, %o2
74; CHECK-LE-NEXT:    call pow
75; CHECK-LE-NEXT:    mov %o1, %o3
76; CHECK-LE-NEXT:    ret
77; CHECK-LE-NEXT:    restore
78  %1 = call double @llvm.pow.f64(double 2.0, double 2.0)
79  ret double %1
80}
81