1 ; RUN: opt < %s -instcombine -S | FileCheck %s
3 define double @std_cabs([2 x double] %z) {
4 ; CHECK-LABEL: define double @std_cabs(
5 ; CHECK: tail call double @cabs(
6 %call = tail call double @cabs([2 x double] %z)
10 define float @std_cabsf([2 x float] %z) {
11 ; CHECK-LABEL: define float @std_cabsf(
12 ; CHECK: tail call float @cabsf(
13 %call = tail call float @cabsf([2 x float] %z)
17 define fp128 @std_cabsl([2 x fp128] %z) {
18 ; CHECK-LABEL: define fp128 @std_cabsl(
19 ; CHECK: tail call fp128 @cabsl(
20 %call = tail call fp128 @cabsl([2 x fp128] %z)
24 define double @fast_cabs([2 x double] %z) {
25 ; CHECK-LABEL: define double @fast_cabs(
26 ; CHECK: %real = extractvalue [2 x double] %z, 0
27 ; CHECK: %imag = extractvalue [2 x double] %z, 1
28 ; CHECK: %1 = fmul fast double %real, %real
29 ; CHECK: %2 = fmul fast double %imag, %imag
30 ; CHECK: %3 = fadd fast double %1, %2
31 ; CHECK: %cabs = call fast double @llvm.sqrt.f64(double %3)
32 ; CHECK: ret double %cabs
33 %call = tail call fast double @cabs([2 x double] %z)
37 define float @fast_cabsf([2 x float] %z) {
38 ; CHECK-LABEL: define float @fast_cabsf(
39 ; CHECK: %real = extractvalue [2 x float] %z, 0
40 ; CHECK: %imag = extractvalue [2 x float] %z, 1
41 ; CHECK: %1 = fmul fast float %real, %real
42 ; CHECK: %2 = fmul fast float %imag, %imag
43 ; CHECK: %3 = fadd fast float %1, %2
44 ; CHECK: %cabs = call fast float @llvm.sqrt.f32(float %3)
45 ; CHECK: ret float %cabs
46 %call = tail call fast float @cabsf([2 x float] %z)
50 define fp128 @fast_cabsl([2 x fp128] %z) {
51 ; CHECK-LABEL: define fp128 @fast_cabsl(
52 ; CHECK: %real = extractvalue [2 x fp128] %z, 0
53 ; CHECK: %imag = extractvalue [2 x fp128] %z, 1
54 ; CHECK: %1 = fmul fast fp128 %real, %real
55 ; CHECK: %2 = fmul fast fp128 %imag, %imag
56 ; CHECK: %3 = fadd fast fp128 %1, %2
57 ; CHECK: %cabs = call fast fp128 @llvm.sqrt.f128(fp128 %3)
58 ; CHECK: ret fp128 %cabs
59 %call = tail call fast fp128 @cabsl([2 x fp128] %z)
63 declare double @cabs([2 x double])
64 declare float @cabsf([2 x float])
65 declare fp128 @cabsl([2 x fp128])