|
| 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=fortran -o - | FileCheck %s --check-prefix=FRTRN |
| 4 | + |
| 5 | +// FRTRN-LABEL: define dso_local <2 x float> @div( |
| 6 | +// FRTRN-SAME: <2 x float> noundef [[A_COERCE:%.*]], <2 x float> noundef [[B_COERCE:%.*]]) #[[ATTR0:[0-9]+]] { |
| 7 | +// FRTRN-NEXT: entry: |
| 8 | +// FRTRN-NEXT: [[RETVAL:%.*]] = alloca { float, float }, align 4 |
| 9 | +// FRTRN-NEXT: [[A:%.*]] = alloca { float, float }, align 4 |
| 10 | +// FRTRN-NEXT: [[B:%.*]] = alloca { float, float }, align 4 |
| 11 | +// FRTRN-NEXT: store <2 x float> [[A_COERCE]], ptr [[A]], align 4 |
| 12 | +// FRTRN-NEXT: store <2 x float> [[B_COERCE]], ptr [[B]], align 4 |
| 13 | +// FRTRN-NEXT: [[A_REALP:%.*]] = getelementptr inbounds { float, float }, ptr [[A]], i32 0, i32 0 |
| 14 | +// FRTRN-NEXT: [[A_REAL:%.*]] = load float, ptr [[A_REALP]], align 4 |
| 15 | +// FRTRN-NEXT: [[A_IMAGP:%.*]] = getelementptr inbounds { float, float }, ptr [[A]], i32 0, i32 1 |
| 16 | +// FRTRN-NEXT: [[A_IMAG:%.*]] = load float, ptr [[A_IMAGP]], align 4 |
| 17 | +// FRTRN-NEXT: [[B_REALP:%.*]] = getelementptr inbounds { float, float }, ptr [[B]], i32 0, i32 0 |
| 18 | +// FRTRN-NEXT: [[B_REAL:%.*]] = load float, ptr [[B_REALP]], align 4 |
| 19 | +// FRTRN-NEXT: [[B_IMAGP:%.*]] = getelementptr inbounds { float, float }, ptr [[B]], i32 0, i32 1 |
| 20 | +// FRTRN-NEXT: [[B_IMAG:%.*]] = load float, ptr [[B_IMAGP]], align 4 |
| 21 | +// FRTRN-NEXT: [[TMP0:%.*]] = call float @llvm.fabs.f32(float [[B_REAL]]) |
| 22 | +// FRTRN-NEXT: [[TMP1:%.*]] = call float @llvm.fabs.f32(float [[B_IMAG]]) |
| 23 | +// FRTRN-NEXT: [[ABS_CMP:%.*]] = fcmp ugt float [[TMP0]], [[TMP1]] |
| 24 | +// FRTRN-NEXT: br i1 [[ABS_CMP]], label [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI:%.*]], label [[ABS_RHSR_LESS_THAN_ABS_RHSI:%.*]] |
| 25 | +// FRTRN: abs_rhsr_greater_or_equal_abs_rhsi: |
| 26 | +// FRTRN-NEXT: [[TMP2:%.*]] = fdiv float [[B_IMAG]], [[B_REAL]] |
| 27 | +// FRTRN-NEXT: [[TMP3:%.*]] = fmul float [[TMP2]], [[B_IMAG]] |
| 28 | +// FRTRN-NEXT: [[TMP4:%.*]] = fadd float [[B_REAL]], [[TMP3]] |
| 29 | +// FRTRN-NEXT: [[TMP5:%.*]] = fmul float [[A_IMAG]], [[TMP2]] |
| 30 | +// FRTRN-NEXT: [[TMP6:%.*]] = fadd float [[A_REAL]], [[TMP5]] |
| 31 | +// FRTRN-NEXT: [[TMP7:%.*]] = fdiv float [[TMP6]], [[TMP4]] |
| 32 | +// FRTRN-NEXT: [[TMP8:%.*]] = fmul float [[A_REAL]], [[TMP2]] |
| 33 | +// FRTRN-NEXT: [[TMP9:%.*]] = fsub float [[A_IMAG]], [[TMP8]] |
| 34 | +// FRTRN-NEXT: [[TMP10:%.*]] = fdiv float [[TMP9]], [[TMP4]] |
| 35 | +// FRTRN-NEXT: br label [[COMPLEX_DIV:%.*]] |
| 36 | +// FRTRN: abs_rhsr_less_than_abs_rhsi: |
| 37 | +// FRTRN-NEXT: [[TMP11:%.*]] = fdiv float [[B_REAL]], [[B_IMAG]] |
| 38 | +// FRTRN-NEXT: [[TMP12:%.*]] = fmul float [[TMP11]], [[B_REAL]] |
| 39 | +// FRTRN-NEXT: [[TMP13:%.*]] = fadd float [[B_IMAG]], [[TMP12]] |
| 40 | +// FRTRN-NEXT: [[TMP14:%.*]] = fmul float [[A_REAL]], [[TMP11]] |
| 41 | +// FRTRN-NEXT: [[TMP15:%.*]] = fadd float [[TMP14]], [[A_IMAG]] |
| 42 | +// FRTRN-NEXT: [[TMP16:%.*]] = fdiv float [[TMP15]], [[TMP13]] |
| 43 | +// FRTRN-NEXT: [[TMP17:%.*]] = fmul float [[A_IMAG]], [[TMP11]] |
| 44 | +// FRTRN-NEXT: [[TMP18:%.*]] = fsub float [[TMP17]], [[A_REAL]] |
| 45 | +// FRTRN-NEXT: [[TMP19:%.*]] = fdiv float [[TMP18]], [[TMP13]] |
| 46 | +// FRTRN-NEXT: br label [[COMPLEX_DIV]] |
| 47 | +// FRTRN: complex_div: |
| 48 | +// FRTRN-NEXT: [[TMP20:%.*]] = phi float [ [[TMP7]], [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI]] ], [ [[TMP16]], [[ABS_RHSR_LESS_THAN_ABS_RHSI]] ] |
| 49 | +// FRTRN-NEXT: [[TMP21:%.*]] = phi float [ [[TMP10]], [[ABS_RHSR_GREATER_OR_EQUAL_ABS_RHSI]] ], [ [[TMP19]], [[ABS_RHSR_LESS_THAN_ABS_RHSI]] ] |
| 50 | +// FRTRN-NEXT: [[RETVAL_REALP:%.*]] = getelementptr inbounds { float, float }, ptr [[RETVAL]], i32 0, i32 0 |
| 51 | +// FRTRN-NEXT: [[RETVAL_IMAGP:%.*]] = getelementptr inbounds { float, float }, ptr [[RETVAL]], i32 0, i32 1 |
| 52 | +// FRTRN-NEXT: store float [[TMP20]], ptr [[RETVAL_REALP]], align 4 |
| 53 | +// FRTRN-NEXT: store float [[TMP21]], ptr [[RETVAL_IMAGP]], align 4 |
| 54 | +// FRTRN-NEXT: [[TMP22:%.*]] = load <2 x float>, ptr [[RETVAL]], align 4 |
| 55 | +// FRTRN-NEXT: ret <2 x float> [[TMP22]] |
| 56 | +// |
| 57 | +_Complex float div(_Complex float a, _Complex float b) { |
| 58 | + return a / b; |
| 59 | +} |
0 commit comments