1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2; RUN: opt < %s -instcombine -S | FileCheck %s
3
4define double @std_cabs(double %real, double %imag) {
5; CHECK-LABEL: @std_cabs(
6; CHECK-NEXT:    [[CALL:%.*]] = tail call double @cabs(double [[REAL:%.*]], double [[IMAG:%.*]])
7; CHECK-NEXT:    ret double [[CALL]]
8;
9  %call = tail call double @cabs(double %real, double %imag)
10  ret double %call
11}
12
13define float @std_cabsf(float %real, float %imag) {
14; CHECK-LABEL: @std_cabsf(
15; CHECK-NEXT:    [[CALL:%.*]] = tail call float @cabsf(float [[REAL:%.*]], float [[IMAG:%.*]])
16; CHECK-NEXT:    ret float [[CALL]]
17;
18  %call = tail call float @cabsf(float %real, float %imag)
19  ret float %call
20}
21
22define fp128 @std_cabsl(fp128 %real, fp128 %imag) {
23; CHECK-LABEL: @std_cabsl(
24; CHECK-NEXT:    [[CALL:%.*]] = tail call fp128 @cabsl(fp128 [[REAL:%.*]], fp128 [[IMAG:%.*]])
25; CHECK-NEXT:    ret fp128 [[CALL]]
26;
27  %call = tail call fp128 @cabsl(fp128 %real, fp128 %imag)
28  ret fp128 %call
29}
30
31define double @fast_cabs(double %real, double %imag) {
32; CHECK-LABEL: @fast_cabs(
33; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast double [[REAL:%.*]], [[REAL]]
34; CHECK-NEXT:    [[TMP2:%.*]] = fmul fast double [[IMAG:%.*]], [[IMAG]]
35; CHECK-NEXT:    [[TMP3:%.*]] = fadd fast double [[TMP1]], [[TMP2]]
36; CHECK-NEXT:    [[CABS:%.*]] = call fast double @llvm.sqrt.f64(double [[TMP3]])
37; CHECK-NEXT:    ret double [[CABS]]
38;
39  %call = tail call fast double @cabs(double %real, double %imag)
40  ret double %call
41}
42
43define float @fast_cabsf(float %real, float %imag) {
44; CHECK-LABEL: @fast_cabsf(
45; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast float [[REAL:%.*]], [[REAL]]
46; CHECK-NEXT:    [[TMP2:%.*]] = fmul fast float [[IMAG:%.*]], [[IMAG]]
47; CHECK-NEXT:    [[TMP3:%.*]] = fadd fast float [[TMP1]], [[TMP2]]
48; CHECK-NEXT:    [[CABS:%.*]] = call fast float @llvm.sqrt.f32(float [[TMP3]])
49; CHECK-NEXT:    ret float [[CABS]]
50;
51  %call = tail call fast float @cabsf(float %real, float %imag)
52  ret float %call
53}
54
55define fp128 @fast_cabsl(fp128 %real, fp128 %imag) {
56; CHECK-LABEL: @fast_cabsl(
57; CHECK-NEXT:    [[TMP1:%.*]] = fmul fast fp128 [[REAL:%.*]], [[REAL]]
58; CHECK-NEXT:    [[TMP2:%.*]] = fmul fast fp128 [[IMAG:%.*]], [[IMAG]]
59; CHECK-NEXT:    [[TMP3:%.*]] = fadd fast fp128 [[TMP1]], [[TMP2]]
60; CHECK-NEXT:    [[CABS:%.*]] = call fast fp128 @llvm.sqrt.f128(fp128 [[TMP3]])
61; CHECK-NEXT:    ret fp128 [[CABS]]
62;
63  %call = tail call fast fp128 @cabsl(fp128 %real, fp128 %imag)
64  ret fp128 %call
65}
66
67declare double @cabs(double %real, double %imag)
68declare float @cabsf(float %real, float %imag)
69declare fp128 @cabsl(fp128 %real, fp128 %imag)
70