summaryrefslogtreecommitdiff
path: root/test/CodeGen/X86/rounding-ops.ll
blob: 51fcf6418429dcd8897442942ff4f97ec5050c11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
; RUN: llc < %s -mtriple=x86_64-apple-macosx -mattr=+sse41 | FileCheck -check-prefix=CHECK-SSE %s
; RUN: llc < %s -mtriple=x86_64-apple-macosx -mattr=+avx | FileCheck -check-prefix=CHECK-AVX %s

define float @test1(float %x) nounwind  {
  %call = tail call float @floorf(float %x) nounwind readnone
  ret float %call

; CHECK-SSE: test1:
; CHECK-SSE: roundss $1

; CHECK-AVX: test1:
; CHECK-AVX: vroundss $1
}

declare float @floorf(float) nounwind readnone

define double @test2(double %x) nounwind  {
  %call = tail call double @floor(double %x) nounwind readnone
  ret double %call

; CHECK-SSE: test2:
; CHECK-SSE: roundsd $1

; CHECK-AVX: test2:
; CHECK-AVX: vroundsd $1
}

declare double @floor(double) nounwind readnone

define float @test3(float %x) nounwind  {
  %call = tail call float @nearbyintf(float %x) nounwind readnone
  ret float %call

; CHECK-SSE: test3:
; CHECK-SSE: roundss $12

; CHECK-AVX: test3:
; CHECK-AVX: vroundss $12
}

declare float @nearbyintf(float) nounwind readnone

define double @test4(double %x) nounwind  {
  %call = tail call double @nearbyint(double %x) nounwind readnone
  ret double %call

; CHECK-SSE: test4:
; CHECK-SSE: roundsd $12

; CHECK-AVX: test4:
; CHECK-AVX: vroundsd $12
}

declare double @nearbyint(double) nounwind readnone

define float @test5(float %x) nounwind  {
  %call = tail call float @ceilf(float %x) nounwind readnone
  ret float %call

; CHECK-SSE: test5:
; CHECK-SSE: roundss $2

; CHECK-AVX: test5:
; CHECK-AVX: vroundss $2
}

declare float @ceilf(float) nounwind readnone

define double @test6(double %x) nounwind  {
  %call = tail call double @ceil(double %x) nounwind readnone
  ret double %call

; CHECK-SSE: test6:
; CHECK-SSE: roundsd $2

; CHECK-AVX: test6:
; CHECK-AVX: vroundsd $2
}

declare double @ceil(double) nounwind readnone

define float @test7(float %x) nounwind  {
  %call = tail call float @rintf(float %x) nounwind readnone
  ret float %call

; CHECK-SSE: test7:
; CHECK-SSE: roundss $4

; CHECK-AVX: test7:
; CHECK-AVX: vroundss $4
}

declare float @rintf(float) nounwind readnone

define double @test8(double %x) nounwind  {
  %call = tail call double @rint(double %x) nounwind readnone
  ret double %call

; CHECK-SSE: test8:
; CHECK-SSE: roundsd $4

; CHECK-AVX: test8:
; CHECK-AVX: vroundsd $4
}

declare double @rint(double) nounwind readnone

define float @test9(float %x) nounwind  {
  %call = tail call float @truncf(float %x) nounwind readnone
  ret float %call

; CHECK-SSE: test9:
; CHECK-SSE: roundss $3

; CHECK-AVX: test9:
; CHECK-AVX: vroundss $3
}

declare float @truncf(float) nounwind readnone

define double @test10(double %x) nounwind  {
  %call = tail call double @trunc(double %x) nounwind readnone
  ret double %call

; CHECK-SSE: test10:
; CHECK-SSE: roundsd $3

; CHECK-AVX: test10:
; CHECK-AVX: vroundsd $3
}

declare double @trunc(double) nounwind readnone