MIR Serialization: Serialize the floating point immediate machine operands.
[oota-llvm.git] / test / CodeGen / MIR / NVPTX / floating-point-immediate-operands.mir
1 # RUN: llc -march=nvptx -mcpu=sm_20 -start-after branch-folder -stop-after branch-folder -o /dev/null %s | FileCheck %s
2 # This test ensures that the MIR parser parses floating point constant operands
3 # correctly.
4
5 --- |
6
7   define float @test(float %k, i32 %i) {
8   entry:
9     %0 = fpext float %k to double
10     %1 = fadd double %0, 3.250000e+00
11     %2 = fptrunc double %1 to float
12     %3 = sitofp i32 %i to float
13     %4 = fadd float %3, 6.250000e+00
14     %5 = fmul float %4, %2
15     ret float %5
16   }
17
18   define float @test2(float %k, i32 %i) {
19   entry:
20     %0 = fpext float %k to double
21     %1 = fadd double %0, 0x7FF8000000000000
22     %2 = fptrunc double %1 to float
23     %3 = sitofp i32 %i to float
24     %4 = fadd float %3, 0x7FF8000000000000
25     %5 = fmul float %4, %2
26     ret float %5
27   }
28
29 ...
30 ---
31 name:            test
32 registers:
33   - { id: 0, class: float32regs }
34   - { id: 1, class: float64regs }
35   - { id: 2, class: int32regs }
36   - { id: 3, class: float64regs }
37   - { id: 4, class: float32regs }
38   - { id: 5, class: float32regs }
39   - { id: 6, class: float32regs }
40   - { id: 7, class: float32regs }
41 body:
42   - id:              0
43     name:            entry
44     instructions:
45       - '%0 = LD_f32_avar 0, 4, 1, 2, 32, $test_param_0'
46       - '%1 = CVT_f64_f32 %0, 0'
47       - '%2 = LD_i32_avar 0, 4, 1, 0, 32, $test_param_1'
48 # CHECK: %3 = FADD_rnf64ri %1, double 3.250000e+00
49       - '%3 = FADD_rnf64ri %1, double 3.250000e+00'
50       - '%4 = CVT_f32_f64 %3, 5'
51       - '%5 = CVT_f32_s32 %2, 5'
52 # CHECK: %6 = FADD_rnf32ri %5, float 6.250000e+00
53       - '%6 = FADD_rnf32ri %5, float 6.250000e+00'
54       - '%7 = FMUL_rnf32rr %6, %4'
55       - 'StoreRetvalF32 %7, 0'
56       - Return
57 ...
58 ---
59 name:            test2
60 registers:
61   - { id: 0, class: float32regs }
62   - { id: 1, class: float64regs }
63   - { id: 2, class: int32regs }
64   - { id: 3, class: float64regs }
65   - { id: 4, class: float32regs }
66   - { id: 5, class: float32regs }
67   - { id: 6, class: float32regs }
68   - { id: 7, class: float32regs }
69 body:
70   - id:              0
71     name:            entry
72     instructions:
73       - '%0 = LD_f32_avar 0, 4, 1, 2, 32, $test2_param_0'
74       - '%1 = CVT_f64_f32 %0, 0'
75       - '%2 = LD_i32_avar 0, 4, 1, 0, 32, $test2_param_1'
76 # CHECK: %3 = FADD_rnf64ri %1, double 0x7FF8000000000000
77       - '%3 = FADD_rnf64ri %1, double 0x7FF8000000000000'
78       - '%4 = CVT_f32_f64 %3, 5'
79       - '%5 = CVT_f32_s32 %2, 5'
80 # CHECK: %6 = FADD_rnf32ri %5, float 0x7FF8000000000000
81       - '%6 = FADD_rnf32ri %5, float 0x7FF8000000000000'
82       - '%7 = FMUL_rnf32rr %6, %4'
83       - 'StoreRetvalF32 %7, 0'
84       - Return
85 ...