cabs-discrete.ll
1.93 KB
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
; RUN: opt < %s -instcombine -S | FileCheck %s
define double @std_cabs(double %real, double %imag) {
; CHECK-LABEL: define double @std_cabs(
; CHECK: tail call double @cabs(
%call = tail call double @cabs(double %real, double %imag)
ret double %call
}
define float @std_cabsf(float %real, float %imag) {
; CHECK-LABEL: define float @std_cabsf(
; CHECK: tail call float @cabsf(
%call = tail call float @cabsf(float %real, float %imag)
ret float %call
}
define fp128 @std_cabsl(fp128 %real, fp128 %imag) {
; CHECK-LABEL: define fp128 @std_cabsl(
; CHECK: tail call fp128 @cabsl(
%call = tail call fp128 @cabsl(fp128 %real, fp128 %imag)
ret fp128 %call
}
define double @fast_cabs(double %real, double %imag) {
; CHECK-LABEL: define double @fast_cabs(
; CHECK: %1 = fmul fast double %real, %real
; CHECK: %2 = fmul fast double %imag, %imag
; CHECK: %3 = fadd fast double %1, %2
; CHECK: %cabs = call fast double @llvm.sqrt.f64(double %3)
; CHECK: ret double %cabs
%call = tail call fast double @cabs(double %real, double %imag)
ret double %call
}
define float @fast_cabsf(float %real, float %imag) {
; CHECK-LABEL: define float @fast_cabsf(
; CHECK: %1 = fmul fast float %real, %real
; CHECK: %2 = fmul fast float %imag, %imag
; CHECK: %3 = fadd fast float %1, %2
; CHECK: %cabs = call fast float @llvm.sqrt.f32(float %3)
; CHECK: ret float %cabs
%call = tail call fast float @cabsf(float %real, float %imag)
ret float %call
}
define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
; CHECK-LABEL: define fp128 @fast_cabsl(
; CHECK: %1 = fmul fast fp128 %real, %real
; CHECK: %2 = fmul fast fp128 %imag, %imag
; CHECK: %3 = fadd fast fp128 %1, %2
; CHECK: %cabs = call fast fp128 @llvm.sqrt.f128(fp128 %3)
; CHECK: ret fp128 %cabs
%call = tail call fast fp128 @cabsl(fp128 %real, fp128 %imag)
ret fp128 %call
}
declare double @cabs(double %real, double %imag)
declare float @cabsf(float %real, float %imag)
declare fp128 @cabsl(fp128 %real, fp128 %imag)