1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -instcombine -S | FileCheck %s
4 define double @std_cabs([2 x double] %z) {
5 ; CHECK-LABEL: @std_cabs(
6 ; CHECK-NEXT: [[CALL:%.*]] = tail call double @cabs([2 x double] [[Z:%.*]])
7 ; CHECK-NEXT: ret double [[CALL]]
9 %call = tail call double @cabs([2 x double] %z)
13 define float @std_cabsf([2 x float] %z) {
14 ; CHECK-LABEL: @std_cabsf(
15 ; CHECK-NEXT: [[CALL:%.*]] = tail call float @cabsf([2 x float] [[Z:%.*]])
16 ; CHECK-NEXT: ret float [[CALL]]
18 %call = tail call float @cabsf([2 x float] %z)
22 define fp128 @std_cabsl([2 x fp128] %z) {
23 ; CHECK-LABEL: @std_cabsl(
24 ; CHECK-NEXT: [[CALL:%.*]] = tail call fp128 @cabsl([2 x fp128] [[Z:%.*]])
25 ; CHECK-NEXT: ret fp128 [[CALL]]
27 %call = tail call fp128 @cabsl([2 x fp128] %z)
31 define double @fast_cabs([2 x double] %z) {
32 ; CHECK-LABEL: @fast_cabs(
33 ; CHECK-NEXT: [[REAL:%.*]] = extractvalue [2 x double] [[Z:%.*]], 0
34 ; CHECK-NEXT: [[IMAG:%.*]] = extractvalue [2 x double] [[Z]], 1
35 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast double [[REAL]], [[REAL]]
36 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast double [[IMAG]], [[IMAG]]
37 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast double [[TMP1]], [[TMP2]]
38 ; CHECK-NEXT: [[CABS:%.*]] = call fast double @llvm.sqrt.f64(double [[TMP3]])
39 ; CHECK-NEXT: ret double [[CABS]]
41 %call = tail call fast double @cabs([2 x double] %z)
45 define float @fast_cabsf([2 x float] %z) {
46 ; CHECK-LABEL: @fast_cabsf(
47 ; CHECK-NEXT: [[REAL:%.*]] = extractvalue [2 x float] [[Z:%.*]], 0
48 ; CHECK-NEXT: [[IMAG:%.*]] = extractvalue [2 x float] [[Z]], 1
49 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast float [[REAL]], [[REAL]]
50 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast float [[IMAG]], [[IMAG]]
51 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast float [[TMP1]], [[TMP2]]
52 ; CHECK-NEXT: [[CABS:%.*]] = call fast float @llvm.sqrt.f32(float [[TMP3]])
53 ; CHECK-NEXT: ret float [[CABS]]
55 %call = tail call fast float @cabsf([2 x float] %z)
59 define fp128 @fast_cabsl([2 x fp128] %z) {
60 ; CHECK-LABEL: @fast_cabsl(
61 ; CHECK-NEXT: [[REAL:%.*]] = extractvalue [2 x fp128] [[Z:%.*]], 0
62 ; CHECK-NEXT: [[IMAG:%.*]] = extractvalue [2 x fp128] [[Z]], 1
63 ; CHECK-NEXT: [[TMP1:%.*]] = fmul fast fp128 [[REAL]], [[REAL]]
64 ; CHECK-NEXT: [[TMP2:%.*]] = fmul fast fp128 [[IMAG]], [[IMAG]]
65 ; CHECK-NEXT: [[TMP3:%.*]] = fadd fast fp128 [[TMP1]], [[TMP2]]
66 ; CHECK-NEXT: [[CABS:%.*]] = call fast fp128 @llvm.sqrt.f128(fp128 [[TMP3]])
67 ; CHECK-NEXT: ret fp128 [[CABS]]
69 %call = tail call fast fp128 @cabsl([2 x fp128] %z)
73 declare double @cabs([2 x double])
74 declare float @cabsf([2 x float])
75 declare fp128 @cabsl([2 x fp128])