aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen/JS/ffis.ll
blob: 9e3de7bad1f8f3024aefcd933b754f429d5aa44f (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
; RUN: llc -march=js < %s | FileCheck %s

; Use proper types to ffi calls, no float32

; CHECK:      (+Math_sqrt(+1));
; CHECK-NEXT: (+Math_sqrt(+1));
; CHECK-NEXT: (+Math_sqrt((+$d)));
; CHECK-NEXT: (+Math_sqrt((+$f)));
; CHECK-NEXT: (+Math_ceil(+1));
; CHECK-NEXT: (+Math_ceil(+1));
; CHECK-NEXT: (+Math_floor(+1));
; CHECK-NEXT: (+Math_floor(+1));
; CHECK-NEXT: (+_min(+1,+1));
; CHECK-NEXT: (+_fmin(+1,+1));
; CHECK-NEXT: (+_max(+1,+1));
; CHECK-NEXT: (+_fmax(+1,+1));
; CHECK-NEXT: (+Math_abs(+1));
; CHECK-NEXT: (+_absf(+1));
; CHECK-NEXT: (+Math_sin(+1));
; CHECK-NEXT: (+Math_sin(+1));
define void @foo(i32 %x) {
entry:
  %f = fadd float 1.0, 2.0
  %d = fadd double 1.0, 2.0

  %sqrtd = call double @sqrt(double 1.0)
  %sqrtf = call float @sqrtf(float 1.0)
  %sqrtdv = call double @sqrt(double %d) ; check vars too
  %sqrtfv = call float @sqrtf(float %f)

  %ceild = call double @ceil(double 1.0)
  %ceilf = call float @ceilf(float 1.0)

  %floord = call double @floor(double 1.0)
  %floorf = call float @floorf(float 1.0)

  ; these could be optimized in theory

  %mind = call double @min(double 1.0, double 1.0)
  %minf = call float @fmin(float 1.0, float 1.0)

  %maxd = call double @max(double 1.0, double 1.0)
  %maxf = call float @fmax(float 1.0, float 1.0)

  %absd = call double @abs(double 1.0)
  %absf = call float @absf(float 1.0)

  ; sin is NOT optimizable with floats

  %sind = call double @sin(double 1.0)
  %sinf = call float @sinf(float 1.0)

  ret void
}

declare double @sqrt(double %x)
declare float @sqrtf(float %x)

declare double @ceil(double %x)
declare float @ceilf(float %x)

declare double @floor(double %x)
declare float @floorf(float %x)

declare double @min(double %x, double %y)
declare float @fmin(float %x, float %y)

declare double @max(double %x, double %y)
declare float @fmax(float %x, float %y)

declare double @abs(double %x)
declare float @absf(float %x)

declare double @sin(double %x)
declare float @sinf(float %x)

attributes #0 = { nounwind readnone }