Files
TheRock/compiler/amd-llvm/clang/test/CodeGen/promoted-complex-div.c
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

142 lines
4.9 KiB
C

// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
// RUN: -verify -complex-range=promoted -o - | FileCheck %s
// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-unknown \
// RUN: -verify=nopromotion -complex-range=promoted -target-feature -x87 \
// RUN: -o - | FileCheck %s --check-prefix=NOX87
// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
// RUN: -verify=nopromotion -complex-range=promoted -o - \
// RUN: | FileCheck %s --check-prefix=NOX87
// RUN: %clang_cc1 %s -O0 -emit-llvm -triple x86_64-unknown-windows \
// RUN: -verify=nopromotion -complex-range=promoted -target-feature -x87 \
// RUN: -o - | FileCheck %s --check-prefix=NOX87
// expected-no-diagnostics
// CHECK-LABEL: define dso_local <2 x float> @divd
_Complex float divd(_Complex float a, _Complex float b) {
// CHECK: fpext float {{.*}} to double
// CHECK: fpext float {{.*}} to double
// CHECK: fdiv double
// CHECK: fdiv double
// CHECK: fptrunc double {{.*}} to float
// CHECK: fptrunc double {{.*}} to float
// NOX87: fpext float {{.*}} to double
// NOX87: fpext float {{.*}} to double
// NOX87: fdiv double
// NOX87: fdiv double
// NOX87: fptrunc double {{.*}} to float
// NOX87: fptrunc double {{.*}} to float
return a / b;
}
// CHECK-LABEL: define dso_local { double, double } @divf
_Complex double divf(_Complex double a, _Complex double b) {
// CHECK: fpext double {{.*}} to x86_fp80
// CHECK: fpext double {{.*}} to x86_fp80
// CHECK: fdiv x86_fp80
// CHECK: fdiv x86_fp80
// CHECK: fptrunc x86_fp80
// CHECK: fptrunc x86_fp80
// NOX87: call double @llvm.fabs.f64(double {{.*}})
// NOX87-NEXT: call double @llvm.fabs.f64(double {{.*}})
// NOX87-NEXT: fcmp ugt double %{{.*}}, {{.*}}
// NOX87-NEXT: br i1 {{.*}}, label
// NOX87: abs_rhsr_greater_or_equal_abs_rhsi:
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fsub double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: br label {{.*}}
// NOX87: abs_rhsr_less_than_abs_rhsi:
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fsub double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: br label
// NOX87: complex_div:
// NOX87-NEXT: phi double
// NOX87-NEXT: phi double
// NOX87-NEXT: getelementptr inbounds nuw { double, double }, ptr {{.*}}, i32 0, i32 0
// NOX87-NEXT: getelementptr inbounds nuw { double, double }, ptr {{.*}}, i32 0, i32 1
// NOX87-NEXT: store double
// NOX87-NEXT: store double
return a / b; // nopromotion-warning{{excess precision is requested but the target does not support excess precision which may result in observable differences in complex division behavior}}
}
// This test ensures that Clang does not crash when complex element types
// require desugaring under -complex-range=promoted. Previously, a sugared
// typedef element type (e.g., 'typedef double a') caused a crash during
// complex range evaluation in both Sema and CodeGen.
typedef double a;
_Complex double *b;
// CHECK-LABEL: define dso_local void @DivideByComplexZero
void DivideByComplexZero(_Complex double p) {
// CHECK: fpext double {{.*}} to x86_fp80
// CHECK: fpext double {{.*}} to x86_fp80
// CHECK: fmul x86_fp80
// CHECK: fmul x86_fp80
// CHECK: fadd x86_fp80
// CHECK: fmul x86_fp80
// CHECK: fmul x86_fp80
// CHECK: fsub x86_fp80
// CHECK: fdiv x86_fp80
// CHECK: fdiv x86_fp80
// CHECK: fptrunc x86_fp80
// CHECK: fptrunc x86_fp80
// NOX87: call double @llvm.fabs.f64(double {{.*}})
// NOX87-NEXT: call double @llvm.fabs.f64(double {{.*}}
// NOX87-NEXT: fcmp ugt double {{.*}}, {{.*}}
// NOX87-NEXT: br i1 {{.*}}, label
// NOX87: abs_rhsr_greater_or_equal_abs_rhsi:
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fsub double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: br label {{.*}}
// NOX87: abs_rhsr_less_than_abs_rhsi:
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fadd double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: fmul double
// NOX87-NEXT: fsub double
// NOX87-NEXT: fdiv double
// NOX87-NEXT: br label {{.*}}
// NOX87: complex_div:
// NOX87-NEXT: phi double
// NOX87-NEXT: phi double
// NOX87-NEXT: getelementptr inbounds nuw { double, double }, ptr {{.*}}, i32 0, i32 0
// NOX87-NEXT: getelementptr inbounds nuw { double, double }, ptr {{.*}}, i32 0, i32 1
// NOX87-NEXT: store double
// NOX87-NEXT: store double
*b /= p * (a)0;
}