1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define double @std_cabs(double %real, double %imag) {
4 ; CHECK-LABEL: define double @std_cabs(
5 ; CHECK: tail call double @cabs(
6 %call = tail call double @cabs(double %real, double %imag)
10 define float @std_cabsf(float %real, float %imag) {
11 ; CHECK-LABEL: define float @std_cabsf(
12 ; CHECK: tail call float @cabsf(
13 %call = tail call float @cabsf(float %real, float %imag)
17 define fp128 @std_cabsl(fp128 %real, fp128 %imag) {
18 ; CHECK-LABEL: define fp128 @std_cabsl(
19 ; CHECK: tail call fp128 @cabsl(
20 %call = tail call fp128 @cabsl(fp128 %real, fp128 %imag)
24 define double @fast_cabs(double %real, double %imag) {
25 ; CHECK-LABEL: define double @fast_cabs(
26 ; CHECK: %1 = fmul fast double %real, %real
27 ; CHECK: %2 = fmul fast double %imag, %imag
28 ; CHECK: %3 = fadd fast double %1, %2
29 ; CHECK: %cabs = call fast double @llvm.sqrt.f64(double %3)
30 ; CHECK: ret double %cabs
31 %call = tail call fast double @cabs(double %real, double %imag)
35 define float @fast_cabsf(float %real, float %imag) {
36 ; CHECK-LABEL: define float @fast_cabsf(
37 ; CHECK: %1 = fmul fast float %real, %real
38 ; CHECK: %2 = fmul fast float %imag, %imag
39 ; CHECK: %3 = fadd fast float %1, %2
40 ; CHECK: %cabs = call fast float @llvm.sqrt.f32(float %3)
41 ; CHECK: ret float %cabs
42 %call = tail call fast float @cabsf(float %real, float %imag)
46 define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
47 ; CHECK-LABEL: define fp128 @fast_cabsl(
48 ; CHECK: %1 = fmul fast fp128 %real, %real
49 ; CHECK: %2 = fmul fast fp128 %imag, %imag
50 ; CHECK: %3 = fadd fast fp128 %1, %2
51 ; CHECK: %cabs = call fast fp128 @llvm.sqrt.f128(fp128 %3)
52 ; CHECK: ret fp128 %cabs
53 %call = tail call fast fp128 @cabsl(fp128 %real, fp128 %imag)
57 declare double @cabs(double %real, double %imag)
58 declare float @cabsf(float %real, float %imag)
59 declare fp128 @cabsl(fp128 %real, fp128 %imag)