Files
TheRock/compiler/amd-llvm/clang/test/CodeGen/arithmetic-fence-builtin.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

92 lines
3.2 KiB
C

// Test with fast math
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
// RUN: -mreassociate \
// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
//
// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -DFAST \
// RUN: -mreassociate \
// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
//
// Test with fast math and fprotect-parens
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -DFAST \
// RUN: -mreassociate -fprotect-parens -ffp-contract=on\
// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
//
// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -DFAST \
// RUN: -mreassociate -fprotect-parens -ffp-contract=on\
// RUN: -o - %s | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKPP %s
//
// Test without fast math: llvm intrinsic not created
// RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -fprotect-parens\
// RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
//
// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -fprotect-parens\
// RUN: -o - %s | FileCheck --implicit-check-not="llvm.arithmetic.fence" %s
//
// Test with fast math on spir target
// RUN: %clang_cc1 -triple spir64 -emit-llvm -DFAST \
// RUN: -mreassociate -o - %s \
// RUN: | FileCheck --check-prefixes CHECK,CHECKFAST,CHECKNP %s
//
int v;
int addit(float a, float b) {
// CHECK: define {{.*}}@addit(float noundef %a, float noundef %b) #0 {
_Complex double cd, cd1;
cd = __arithmetic_fence(cd1);
// CHECKFAST: call{{.*}} double @llvm.arithmetic.fence.f64({{.*}}real)
// CHECKFAST: call{{.*}} double @llvm.arithmetic.fence.f64({{.*}}imag)
// Vector should be supported.
typedef float __v2f32 __attribute__((__vector_size__(8)));
__v2f32 vec1, vec2;
vec1 = __arithmetic_fence(vec2);
// CHECKFAST: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f32
vec2 = (vec2 + vec1);
// CHECKPP: call{{.*}} <2 x float> @llvm.arithmetic.fence.v2f32
v = __arithmetic_fence(a + b);
// CHECKFAST: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})
v = (a + b);
// CHECKPP: call{{.*}} float @llvm.arithmetic.fence.f32(float %add{{.*}})
v = a + (b*b);
// CHECKPP: fmul reassoc
// CHECKPP-NEXT: call{{.*}} float @llvm.arithmetic.fence.f32(float %mul)
// CHECKNP: fmul
// CHECKNP: fadd
v = b + a*a;
// CHECKPP: call{{.*}} float @llvm.fmuladd.f32
// CHECKNP: fmul
// CHECKNP: fadd
v = b + __arithmetic_fence(a*a); // Fence blocks recognition of FMA
// CHECKPP: fmul
// CHECKNP: fmul
b = (a);
(a) = b;
// CHECK-NEXT fptosi
// CHECK-NEXT store i32
// CHECK-NEXT load float
// CHECK-NEXT store float
// CHECK-NEXT load float
// CHECK-NEXT store float
return 0;
// CHECK-NEXT ret i32 0
}
int addit1(int a, int b) {
// CHECK: define {{.*}}@addit1(i32 noundef %a, i32 noundef %b{{.*}}
v = (a + b);
// CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.int(float noundef %add)
return 0;
}
#ifdef FAST
#pragma float_control(precise, on)
int subit(float a, float b, float *fp) {
// CHECKFAST: define {{.*}}@subit(float noundef %a, float noundef %b{{.*}}
*fp = __arithmetic_fence(a - b);
*fp = (a + b);
// CHECK-NOT: call{{.*}} float @llvm.arithmetic.fence.f32(float noundef %add)
return 0;
}
#endif