64 lines · plain
1// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \2// RUN: -target-cpu gfx906 -fcuda-is-device -x hip \3// RUN: | FileCheck --check-prefixes=COMMON,CRDIV %s4// RUN: %clang_cc1 %s -emit-llvm -o - -triple -amdgcn-amd-amdhsa \5// RUN: -target-cpu gfx906 -fcuda-is-device -x hip \6// RUN: -fno-hip-fp32-correctly-rounded-divide-sqrt \7// RUN: | FileCheck --check-prefixes=COMMON,NCRDIV %s8 9#include "Inputs/cuda.h"10 11typedef __attribute__(( ext_vector_type(4) )) float floatvec4;12 13// COMMON-LABEL: @_Z11spscalardiv14// COMMON: fdiv{{.*}},15// NCRDIV: !fpmath ![[MD:[0-9]+]]16// CRDIV-NOT: !fpmath17__device__ float spscalardiv(float a, float b) {18 return a / b;19}20 21// COMMON-LABEL: @_Z11spvectordiv22// COMMON: fdiv{{.*}},23// NCRDIV: !fpmath ![[MD]]24// CRDIV-NOT: !fpmath25__device__ floatvec4 spvectordiv(floatvec4 a, floatvec4 b) {26 return a / b;27}28 29// COMMON-LABEL: @_Z11dpscalardiv30// COMMON-NOT: !fpmath31__device__ double dpscalardiv(double a, double b) {32 return a / b;33}34 35// COMMON-LABEL: @_Z12spscalarsqrt36// NCRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]37// CRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}){{$}}38__device__ float spscalarsqrt(float a) {39 return __builtin_sqrtf(a);40}41 42// COMMON-LABEL: @_Z12dpscalarsqrt43// COMMON: call contract double @llvm.sqrt.f64(double %{{.+}}){{$}}44// COMMON-NOT: !fpmath45__device__ double dpscalarsqrt(double a) {46 return __builtin_sqrt(a);47}48 49// COMMON-LABEL: @_Z28test_builtin_elementwise_f32f50// NCRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}), !fpmath ![[MD:[0-9]+]]51// CRDIV: call contract float @llvm.sqrt.f32(float %{{.+}}){{$}}52__device__ float test_builtin_elementwise_f32(float a) {53 return __builtin_elementwise_sqrt(a);54}55 56// COMMON-LABEL: @_Z28test_builtin_elementwise_f64d57// COMMON: call contract double @llvm.sqrt.f64(double %{{.+}}){{$}}58// COMMON-NOT: !fpmath59__device__ double test_builtin_elementwise_f64(double a) {60 return __builtin_elementwise_sqrt(a);61}62 63// NCRSQRT: ![[MD]] = !{float 2.500000e+00}64