Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / smiths-complex-div.c
blobdbc5462bf64be9bf3a8e96c56052c754b6f04b7d
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 4
2 // RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
3 // RUN: -complex-range=improved -o - | FileCheck %s --check-prefix=IMPRVD
5 // IMPRVD-LABEL: define dso_local <2 x float> @div(
6 // IMPRVD-SAME: <2 x float> noundef [[A_COERCE:%.*]], <2 x float> noundef [[B_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
7 // IMPRVD-NEXT: entry:
8 // IMPRVD-NEXT: [[RETVAL:%.*]] = alloca { float, float }, align 4
9 // IMPRVD-NEXT: [[A:%.*]] = alloca { float, float }, align 4
10 // IMPRVD-NEXT: [[B:%.*]] = alloca { float, float }, align 4
11 // IMPRVD-NEXT: store <2 x float> [[A_COERCE]], ptr [[A]], align 4
12 // IMPRVD-NEXT: store <2 x float> [[B_COERCE]], ptr [[B]], align 4
13 // IMPRVD-NEXT: [[A_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 0
14 // IMPRVD-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 4
15 // IMPRVD-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[A]], i32 0, i32 1
16 // IMPRVD-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 4
17 // IMPRVD-NEXT: [[B_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 0
18 // IMPRVD-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 4
19 // IMPRVD-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[B]], i32 0, i32 1
20 // IMPRVD-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 4
21 // IMPRVD-NEXT: [[TMP0:%.*]] = call float @llvm.fabs.f32(float [[B_REAL]])
22 // IMPRVD-NEXT: [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[B_IMAG]])
23 // IMPRVD-NEXT: [[ABS_CMP:%.*]] = fcmp ugt float [[TMP0]], [[TMP1]]
24 // IMPRVD-NEXT: br i1 [[ABS_CMP]], label [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI:%.*]], label [[ABS_RHSR_LESS_THAN_ABS_RHSI:%.*]]
25 // IMPRVD: abs_rhsr_greater_or_equal_abs_rhsi:
26 // IMPRVD-NEXT: [[TMP2:%.*]] = fdiv float [[B_IMAG]], [[B_REAL]]
27 // IMPRVD-NEXT: [[TMP3:%.*]] = fmul float [[TMP2]], [[B_IMAG]]
28 // IMPRVD-NEXT: [[TMP4:%.*]] = fadd float [[B_REAL]], [[TMP3]]
29 // IMPRVD-NEXT: [[TMP5:%.*]] = fmul float [[A_IMAG]], [[TMP2]]
30 // IMPRVD-NEXT: [[TMP6:%.*]] = fadd float [[A_REAL]], [[TMP5]]
31 // IMPRVD-NEXT: [[TMP7:%.*]] = fdiv float [[TMP6]], [[TMP4]]
32 // IMPRVD-NEXT: [[TMP8:%.*]] = fmul float [[A_REAL]], [[TMP2]]
33 // IMPRVD-NEXT: [[TMP9:%.*]] = fsub float [[A_IMAG]], [[TMP8]]
34 // IMPRVD-NEXT: [[TMP10:%.*]] = fdiv float [[TMP9]], [[TMP4]]
35 // IMPRVD-NEXT: br label [[COMPLEX_DIV:%.*]]
36 // IMPRVD: abs_rhsr_less_than_abs_rhsi:
37 // IMPRVD-NEXT: [[TMP11:%.*]] = fdiv float [[B_REAL]], [[B_IMAG]]
38 // IMPRVD-NEXT: [[TMP12:%.*]] = fmul float [[TMP11]], [[B_REAL]]
39 // IMPRVD-NEXT: [[TMP13:%.*]] = fadd float [[B_IMAG]], [[TMP12]]
40 // IMPRVD-NEXT: [[TMP14:%.*]] = fmul float [[A_REAL]], [[TMP11]]
41 // IMPRVD-NEXT: [[TMP15:%.*]] = fadd float [[TMP14]], [[A_IMAG]]
42 // IMPRVD-NEXT: [[TMP16:%.*]] = fdiv float [[TMP15]], [[TMP13]]
43 // IMPRVD-NEXT: [[TMP17:%.*]] = fmul float [[A_IMAG]], [[TMP11]]
44 // IMPRVD-NEXT: [[TMP18:%.*]] = fsub float [[TMP17]], [[A_REAL]]
45 // IMPRVD-NEXT: [[TMP19:%.*]] = fdiv float [[TMP18]], [[TMP13]]
46 // IMPRVD-NEXT: br label [[COMPLEX_DIV]]
47 // IMPRVD: complex_div:
48 // IMPRVD-NEXT: [[TMP20:%.*]] = phi float [ [[TMP7]], [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI]] ], [ [[TMP16]], [[ABS_RHSR_LESS_THAN_ABS_RHSI]] ]
49 // IMPRVD-NEXT: [[TMP21:%.*]] = phi float [ [[TMP10]], [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI]] ], [ [[TMP19]], [[ABS_RHSR_LESS_THAN_ABS_RHSI]] ]
50 // IMPRVD-NEXT: [[RETVAL_REALP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[RETVAL]], i32 0, i32 0
51 // IMPRVD-NEXT: [[RETVAL_IMAGP:%.*]] = getelementptr inbounds nuw { float, float }, ptr [[RETVAL]], i32 0, i32 1
52 // IMPRVD-NEXT: store float [[TMP20]], ptr [[RETVAL_REALP]], align 4
53 // IMPRVD-NEXT: store float [[TMP21]], ptr [[RETVAL_IMAGP]], align 4
54 // IMPRVD-NEXT: [[TMP22:%.*]] = load <2 x float>, ptr [[RETVAL]], align 4
55 // IMPRVD-NEXT: ret <2 x float> [[TMP22]]
57 _Complex float div(_Complex float a, _Complex float b) {
58 return a / b;