Author: Sarah Spall
Date: 2025-03-26T07:54:13-07:00
New Revision: c3e08c8f07ded9ef0d1ad2f3fb04e98d839479b1

URL: 
https://github.com/llvm/llvm-project/commit/c3e08c8f07ded9ef0d1ad2f3fb04e98d839479b1
DIFF: 
https://github.com/llvm/llvm-project/commit/c3e08c8f07ded9ef0d1ad2f3fb04e98d839479b1.diff

LOG: [HLSL] Add new double overloads for math builtins (#132979)

Add double overloads which cast the double to a float and call the float
builtin.
Makes these double overloads conditional on hlsl version 202x or
earlier.
Add tests
Closes #128228

Added: 
    

Modified: 
    clang/lib/Frontend/InitPreprocessor.cpp
    clang/lib/Headers/hlsl.h
    clang/lib/Headers/hlsl/hlsl_compat_overloads.h
    clang/test/CodeGenHLSL/builtins/acos.hlsl
    clang/test/CodeGenHLSL/builtins/asin.hlsl
    clang/test/CodeGenHLSL/builtins/atan.hlsl
    clang/test/CodeGenHLSL/builtins/atan2.hlsl
    clang/test/CodeGenHLSL/builtins/ceil.hlsl
    clang/test/CodeGenHLSL/builtins/cos.hlsl
    clang/test/CodeGenHLSL/builtins/cosh.hlsl
    clang/test/CodeGenHLSL/builtins/degrees.hlsl
    clang/test/CodeGenHLSL/builtins/exp.hlsl
    clang/test/CodeGenHLSL/builtins/exp2.hlsl
    clang/test/CodeGenHLSL/builtins/floor.hlsl
    clang/test/CodeGenHLSL/builtins/frac.hlsl
    clang/test/CodeGenHLSL/builtins/isinf.hlsl
    clang/test/CodeGenHLSL/builtins/lerp.hlsl
    clang/test/CodeGenHLSL/builtins/log.hlsl
    clang/test/CodeGenHLSL/builtins/log10.hlsl
    clang/test/CodeGenHLSL/builtins/log2.hlsl
    clang/test/CodeGenHLSL/builtins/normalize.hlsl
    clang/test/CodeGenHLSL/builtins/pow.hlsl
    clang/test/CodeGenHLSL/builtins/radians.hlsl
    clang/test/CodeGenHLSL/builtins/round.hlsl
    clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
    clang/test/CodeGenHLSL/builtins/sin.hlsl
    clang/test/CodeGenHLSL/builtins/sinh.hlsl
    clang/test/CodeGenHLSL/builtins/sqrt.hlsl
    clang/test/CodeGenHLSL/builtins/step.hlsl
    clang/test/CodeGenHLSL/builtins/tan.hlsl
    clang/test/CodeGenHLSL/builtins/tanh.hlsl
    clang/test/CodeGenHLSL/builtins/trunc.hlsl

Removed: 
    


################################################################################
diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 1a816cb6269d4..0b54665501c76 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -394,6 +394,10 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
     // HLSL Version
     Builder.defineMacro("__HLSL_VERSION",
                         Twine((unsigned)LangOpts.getHLSLVersion()));
+    Builder.defineMacro("__HLSL_202x",
+                        Twine((unsigned)LangOptions::HLSLLangStd::HLSL_202x));
+    Builder.defineMacro("__HLSL_202y",
+                        Twine((unsigned)LangOptions::HLSLLangStd::HLSL_202y));
 
     if (LangOpts.NativeHalfType)
       Builder.defineMacro("__HLSL_ENABLE_16_BIT", "1");

diff  --git a/clang/lib/Headers/hlsl.h b/clang/lib/Headers/hlsl.h
index d233f6092ffcd..b494b4d0f78bb 100644
--- a/clang/lib/Headers/hlsl.h
+++ b/clang/lib/Headers/hlsl.h
@@ -22,7 +22,9 @@
 
 // HLSL standard library function declarations/definitions.
 #include "hlsl/hlsl_alias_intrinsics.h"
+#if __HLSL_VERSION <= __HLSL_202x
 #include "hlsl/hlsl_compat_overloads.h"
+#endif
 #include "hlsl/hlsl_intrinsics.h"
 
 #if defined(__clang__)

diff  --git a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h 
b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
index aff514ef74208..d8dac0a3942ad 100644
--- a/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
+++ b/clang/lib/Headers/hlsl/hlsl_compat_overloads.h
@@ -16,6 +16,70 @@ namespace hlsl {
 // unsigned integer and floating point. Keeping this ordering consistent will
 // help keep this file manageable as it grows.
 
+#define _DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(fn)                                 
\
+  constexpr float fn(double V) { return fn((float)V); }                        
\
+  constexpr float2 fn(double2 V) { return fn((float2)V); }                     
\
+  constexpr float3 fn(double3 V) { return fn((float3)V); }                     
\
+  constexpr float4 fn(double4 V) { return fn((float4)V); }
+
+#define _DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(fn)                                
\
+  constexpr float fn(double V1, double V2) {                                   
\
+    return fn((float)V1, (float)V2);                                           
\
+  }                                                                            
\
+  constexpr float2 fn(double2 V1, double2 V2) {                                
\
+    return fn((float2)V1, (float2)V2);                                         
\
+  }                                                                            
\
+  constexpr float3 fn(double3 V1, double3 V2) {                                
\
+    return fn((float3)V1, (float3)V2);                                         
\
+  }                                                                            
\
+  constexpr float4 fn(double4 V1, double4 V2) {                                
\
+    return fn((float4)V1, (float4)V2);                                         
\
+  }
+
+#define _DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(fn)                               
\
+  constexpr float fn(double V1, double V2, double V3) {                        
\
+    return fn((float)V1, (float)V2, (float)V3);                                
\
+  }                                                                            
\
+  constexpr float2 fn(double2 V1, double2 V2, double2 V3) {                    
\
+    return fn((float2)V1, (float2)V2, (float2)V3);                             
\
+  }                                                                            
\
+  constexpr float3 fn(double3 V1, double3 V2, double3 V3) {                    
\
+    return fn((float3)V1, (float3)V2, (float3)V3);                             
\
+  }                                                                            
\
+  constexpr float4 fn(double4 V1, double4 V2, double4 V3) {                    
\
+    return fn((float4)V1, (float4)V2, (float4)V3);                             
\
+  }
+
+//===----------------------------------------------------------------------===//
+// acos builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(acos)
+
+//===----------------------------------------------------------------------===//
+// asin builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(asin)
+
+//===----------------------------------------------------------------------===//
+// atan builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(atan)
+
+//===----------------------------------------------------------------------===//
+// atan2 builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(atan2)
+
+//===----------------------------------------------------------------------===//
+// ceil builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(ceil)
+
 
//===----------------------------------------------------------------------===//
 // clamp builtins overloads
 
//===----------------------------------------------------------------------===//
@@ -39,7 +103,82 @@ clamp(vector<T, N> p0, T p1, T p2) {
 }
 
 
//===----------------------------------------------------------------------===//
-// max builtin overloads
+// cos builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(cos)
+
+//===----------------------------------------------------------------------===//
+// cosh builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(cosh)
+
+//===----------------------------------------------------------------------===//
+// degrees builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(degrees)
+
+//===----------------------------------------------------------------------===//
+// exp builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(exp)
+
+//===----------------------------------------------------------------------===//
+// exp2 builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(exp2)
+
+//===----------------------------------------------------------------------===//
+// floor builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(floor)
+
+//===----------------------------------------------------------------------===//
+// frac builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(frac)
+
+//===----------------------------------------------------------------------===//
+// isinf builtins overloads
+//===----------------------------------------------------------------------===//
+
+constexpr bool isinf(double V) { return isinf((float)V); }
+constexpr bool2 isinf(double2 V) { return isinf((float2)V); }
+constexpr bool3 isinf(double3 V) { return isinf((float3)V); }
+constexpr bool4 isinf(double4 V) { return isinf((float4)V); }
+
+//===----------------------------------------------------------------------===//
+// lerp builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_TERNARY_DOUBLE_OVERLOADS(lerp)
+
+//===----------------------------------------------------------------------===//
+// log builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(log)
+
+//===----------------------------------------------------------------------===//
+// log10 builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(log10)
+
+//===----------------------------------------------------------------------===//
+// log2 builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(log2)
+
+//===----------------------------------------------------------------------===//
+// max builtins overloads
 
//===----------------------------------------------------------------------===//
 
 template <typename T, uint N>
@@ -55,7 +194,7 @@ max(T p0, vector<T, N> p1) {
 }
 
 
//===----------------------------------------------------------------------===//
-// min builtin overloads
+// min builtins overloads
 
//===----------------------------------------------------------------------===//
 
 template <typename T, uint N>
@@ -70,5 +209,77 @@ min(T p0, vector<T, N> p1) {
   return min((vector<T, N>)p0, p1);
 }
 
+//===----------------------------------------------------------------------===//
+// normalize builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(normalize)
+
+//===----------------------------------------------------------------------===//
+// pow builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(pow)
+
+//===----------------------------------------------------------------------===//
+// rsqrt builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(rsqrt)
+
+//===----------------------------------------------------------------------===//
+// round builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(round)
+
+//===----------------------------------------------------------------------===//
+// sin builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(sin)
+
+//===----------------------------------------------------------------------===//
+// sinh builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(sinh)
+
+//===----------------------------------------------------------------------===//
+// sqrt builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(sqrt)
+
+//===----------------------------------------------------------------------===//
+// step builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_BINARY_DOUBLE_OVERLOADS(step)
+
+//===----------------------------------------------------------------------===//
+// tan builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(tan)
+
+//===----------------------------------------------------------------------===//
+// tanh builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(tanh)
+
+//===----------------------------------------------------------------------===//
+// trunc builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(trunc)
+
+//===----------------------------------------------------------------------===//
+// radians builtins overloads
+//===----------------------------------------------------------------------===//
+
+_DXC_COMPAT_UNARY_DOUBLE_OVERLOADS(radians)
+
 } // namespace hlsl
 #endif // _HLSL_COMPAT_OVERLOADS_H_

diff  --git a/clang/test/CodeGenHLSL/builtins/acos.hlsl 
b/clang/test/CodeGenHLSL/builtins/acos.hlsl
index 8152339a34e87..8bc018321d9c4 100644
--- a/clang/test/CodeGenHLSL/builtins/acos.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/acos.hlsl
@@ -57,3 +57,27 @@ float3 test_acos_float3 ( float3 p0 ) {
 float4 test_acos_float4 ( float4 p0 ) {
   return acos ( p0 );
 }
+
+// CHECK-LABEL: test_acos_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.acos.f32
+float test_acos_double ( double p0 ) {
+  return acos ( p0 );
+}
+
+// CHECK-LABEL: test_acos_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.acos.v2f32
+float2 test_acos_double2 ( double2 p0 ) {
+  return acos ( p0 );
+}
+
+// CHECK-LABEL: test_acos_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.acos.v3f32
+float3 test_acos_double3 ( double3 p0 ) {
+  return acos ( p0 );
+}
+
+// CHECK-LABEL: test_acos_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.acos.v4f32
+float4 test_acos_double4 ( double4 p0 ) {
+  return acos ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/asin.hlsl 
b/clang/test/CodeGenHLSL/builtins/asin.hlsl
index 16efbba79670e..e65844d80cdac 100644
--- a/clang/test/CodeGenHLSL/builtins/asin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/asin.hlsl
@@ -57,3 +57,27 @@ float3 test_asin_float3 ( float3 p0 ) {
 float4 test_asin_float4 ( float4 p0 ) {
   return asin ( p0 );
 }
+
+// CHECK-LABEL: test_asin_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.asin.f32
+float test_asin_double ( double p0 ) {
+  return asin ( p0 );
+}
+
+// CHECK-LABEL: test_asin_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.asin.v2f32
+float2 test_asin_double2 ( double2 p0 ) {
+  return asin ( p0 );
+}
+
+// CHECK-LABEL: test_asin_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.asin.v3f32
+float3 test_asin_double3 ( double3 p0 ) {
+  return asin ( p0 );
+}
+
+// CHECK-LABEL: test_asin_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.asin.v4f32
+float4 test_asin_double4 ( double4 p0 ) {
+  return asin ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/atan.hlsl 
b/clang/test/CodeGenHLSL/builtins/atan.hlsl
index 437835a863703..5be3d79a2bac6 100644
--- a/clang/test/CodeGenHLSL/builtins/atan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/atan.hlsl
@@ -57,3 +57,27 @@ float3 test_atan_float3 ( float3 p0 ) {
 float4 test_atan_float4 ( float4 p0 ) {
   return atan ( p0 );
 }
+
+// CHECK-LABEL: test_atan_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.atan.f32
+float test_atan_double ( double p0 ) {
+  return atan ( p0 );
+}
+
+// CHECK-LABEL: test_atan_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.atan.v2f32
+float2 test_atan_double2 ( double2 p0 ) {
+  return atan ( p0 );
+}
+
+// CHECK-LABEL: test_atan_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.atan.v3f32
+float3 test_atan_double3 ( double3 p0 ) {
+  return atan ( p0 );
+}
+
+// CHECK-LABEL: test_atan_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.atan.v4f32
+float4 test_atan_double4 ( double4 p0 ) {
+  return atan ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/atan2.hlsl 
b/clang/test/CodeGenHLSL/builtins/atan2.hlsl
index 53d115641e72f..b0fe7efc7c310 100644
--- a/clang/test/CodeGenHLSL/builtins/atan2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/atan2.hlsl
@@ -57,3 +57,27 @@ float3 test_atan2_float3 (float3 p0, float3 p1) {
 float4 test_atan2_float4 (float4 p0, float4 p1) {
   return atan2(p0, p1);
 }
+
+// CHECK-LABEL: test_atan2_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.atan2.f32
+float test_atan2_double (double p0, double p1) {
+  return atan2(p0, p1);
+}
+
+// CHECK-LABEL: test_atan2_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.atan2.v2f32
+float2 test_atan2_double2 (double2 p0, double2 p1) {
+  return atan2(p0, p1);
+}
+
+// CHECK-LABEL: test_atan2_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.atan2.v3f32
+float3 test_atan2_double3 (double3 p0, double3 p1) {
+  return atan2(p0, p1);
+}
+
+// CHECK-LABEL: test_atan2_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.atan2.v4f32
+float4 test_atan2_double4 (double4 p0, double4 p1) {
+  return atan2(p0, p1);
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/ceil.hlsl 
b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
index fe0b8f8983838..87cae2548aa76 100644
--- a/clang/test/CodeGenHLSL/builtins/ceil.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/ceil.hlsl
@@ -40,3 +40,16 @@ float3 test_ceil_float3(float3 p0) { return ceil(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z16test_ceil_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.ceil.v4f32(
 float4 test_ceil_float4(float4 p0) { return ceil(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_ceil_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.ceil.f32(
+float test_ceil_double(double p0) { return ceil(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_ceil_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.ceil.v2f32(
+float2 test_ceil_double2(double2 p0) { return ceil(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_ceil_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.ceil.v3f32(
+float3 test_ceil_double3(double3 p0) { return ceil(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_ceil_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.ceil.v4f32(
+float4 test_ceil_double4(double4 p0) { return ceil(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/cos.hlsl 
b/clang/test/CodeGenHLSL/builtins/cos.hlsl
index 5f993d50498bf..745bb9f99f6de 100644
--- a/clang/test/CodeGenHLSL/builtins/cos.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/cos.hlsl
@@ -38,3 +38,16 @@ float3 test_cos_float3(float3 p0) { return cos(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z15test_cos_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.cos.v4f32
 float4 test_cos_float4(float4 p0) { return cos(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_cos_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.cos.f32(
+float test_cos_double(double p0) { return cos(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_cos_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.cos.v2f32
+float2 test_cos_double2(double2 p0) { return cos(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_cos_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.cos.v3f32
+float3 test_cos_double3(double3 p0) { return cos(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_cos_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.cos.v4f32
+float4 test_cos_double4(double4 p0) { return cos(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/cosh.hlsl 
b/clang/test/CodeGenHLSL/builtins/cosh.hlsl
index 07c64206412db..ba2cbdd018a82 100644
--- a/clang/test/CodeGenHLSL/builtins/cosh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/cosh.hlsl
@@ -57,3 +57,27 @@ float3 test_cosh_float3 ( float3 p0 ) {
 float4 test_cosh_float4 ( float4 p0 ) {
   return cosh ( p0 );
 }
+
+// CHECK-LABEL: test_cosh_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.cosh.f32
+float test_cosh_double ( double p0 ) {
+  return cosh ( p0 );
+}
+
+// CHECK-LABEL: test_cosh_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.cosh.v2f32
+float2 test_cosh_double2 ( double2 p0 ) {
+  return cosh ( p0 );
+}
+
+// CHECK-LABEL: test_cosh_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.cosh.v3f32
+float3 test_cosh_double3 ( double3 p0 ) {
+  return cosh ( p0 );
+}
+
+// CHECK-LABEL: test_cosh_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.cosh.v4f32
+float4 test_cosh_double4 ( double4 p0 ) {
+  return cosh ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/degrees.hlsl 
b/clang/test/CodeGenHLSL/builtins/degrees.hlsl
index 64531dd2785eb..6a55b4d5b1be2 100644
--- a/clang/test/CodeGenHLSL/builtins/degrees.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/degrees.hlsl
@@ -62,3 +62,20 @@ float3 test_degrees_float3(float3 p0) { return degrees(p0); }
 // CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].degrees.v4f32
 // CHECK: ret <4 x float> %hlsl.degrees
 float4 test_degrees_float4(float4 p0) { return degrees(p0); }
+
+// CHECK: define [[FNATTRS]] float @
+// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].degrees.f32(
+// CHECK: ret float %hlsl.degrees
+float test_degrees_double(double p0) { return degrees(p0); }
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].degrees.v2f32
+// CHECK: ret <2 x float> %hlsl.degrees
+float2 test_degrees_double2(double2 p0) { return degrees(p0); }
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].degrees.v3f32
+// CHECK: ret <3 x float> %hlsl.degrees
+float3 test_degrees_double3(double3 p0) { return degrees(p0); }
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %hlsl.degrees = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].degrees.v4f32
+// CHECK: ret <4 x float> %hlsl.degrees
+float4 test_degrees_double4(double4 p0) { return degrees(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/exp.hlsl 
b/clang/test/CodeGenHLSL/builtins/exp.hlsl
index 6ed40ed8f433c..dad80fcbcf2d8 100644
--- a/clang/test/CodeGenHLSL/builtins/exp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp.hlsl
@@ -50,3 +50,20 @@ float3 test_exp_float3(float3 p0) { return exp(p0); }
 // CHECK: %elt.exp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.exp.v4f32
 // CHECK: ret <4 x float> %elt.exp
 float4 test_exp_float4(float4 p0) { return exp(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_exp_double
+// CHECK: %elt.exp = call reassoc nnan ninf nsz arcp afn float @llvm.exp.f32(
+// CHECK: ret float %elt.exp
+float test_exp_double(double p0) { return exp(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_exp_double2
+// CHECK: %elt.exp = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.exp.v2f32
+// CHECK: ret <2 x float> %elt.exp
+float2 test_exp_double2(double2 p0) { return exp(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_exp_double3
+// CHECK: %elt.exp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.exp.v3f32
+// CHECK: ret <3 x float> %elt.exp
+float3 test_exp_double3(double3 p0) { return exp(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_exp_double4
+// CHECK: %elt.exp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.exp.v4f32
+// CHECK: ret <4 x float> %elt.exp
+float4 test_exp_double4(double4 p0) { return exp(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/exp2.hlsl 
b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
index b067427e46368..594da9a990424 100644
--- a/clang/test/CodeGenHLSL/builtins/exp2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/exp2.hlsl
@@ -50,3 +50,20 @@ float3 test_exp2_float3(float3 p0) { return exp2(p0); }
 // CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.exp2.v4f32
 // CHECK: ret <4 x float> %elt.exp2
 float4 test_exp2_float4(float4 p0) { return exp2(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_exp2_double
+// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn float @llvm.exp2.f32(
+// CHECK: ret float %elt.exp2
+float test_exp2_double(double p0) { return exp2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_exp2_double2
+// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.exp2.v2f32
+// CHECK: ret <2 x float> %elt.exp2
+float2 test_exp2_double2(double2 p0) { return exp2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_exp2_double3
+// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.exp2.v3f32
+// CHECK: ret <3 x float> %elt.exp2
+float3 test_exp2_double3(double3 p0) { return exp2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_exp2_double4
+// CHECK: %elt.exp2 = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.exp2.v4f32
+// CHECK: ret <4 x float> %elt.exp2
+float4 test_exp2_double4(double4 p0) { return exp2(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/floor.hlsl 
b/clang/test/CodeGenHLSL/builtins/floor.hlsl
index f610baeeefd48..de411746ce467 100644
--- a/clang/test/CodeGenHLSL/builtins/floor.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/floor.hlsl
@@ -40,3 +40,16 @@ float3 test_floor_float3(float3 p0) { return floor(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z17test_floor_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.floor.v4f32(
 float4 test_floor_float4(float4 p0) { return floor(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_floor_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.floor.f32(
+float test_floor_double(double p0) { return floor(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_floor_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.floor.v2f32(
+float2 test_floor_double2(double2 p0) { return floor(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_floor_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.floor.v3f32(
+float3 test_floor_double3(double3 p0) { return floor(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_floor_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.floor.v4f32(
+float4 test_floor_double4(double4 p0) { return floor(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/frac.hlsl 
b/clang/test/CodeGenHLSL/builtins/frac.hlsl
index 7b105ce84359f..71ca8fc0e4518 100644
--- a/clang/test/CodeGenHLSL/builtins/frac.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/frac.hlsl
@@ -62,3 +62,20 @@ float3 test_frac_float3(float3 p0) { return frac(p0); }
 // CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].frac.v4f32
 // CHECK: ret <4 x float> %hlsl.frac
 float4 test_frac_float4(float4 p0) { return frac(p0); }
+
+// CHECK: define [[FNATTRS]] float @
+// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].frac.f32(
+// CHECK: ret float %hlsl.frac
+float test_frac_double(double p0) { return frac(p0); }
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].frac.v2f32
+// CHECK: ret <2 x float> %hlsl.frac
+float2 test_frac_double2(double2 p0) { return frac(p0); }
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].frac.v3f32
+// CHECK: ret <3 x float> %hlsl.frac
+float3 test_frac_double3(double3 p0) { return frac(p0); }
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %hlsl.frac = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].frac.v4f32
+// CHECK: ret <4 x float> %hlsl.frac
+float4 test_frac_double4(double4 p0) { return frac(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/isinf.hlsl 
b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
index df44fc4a91dfd..b734f1bbf5af0 100644
--- a/clang/test/CodeGenHLSL/builtins/isinf.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/isinf.hlsl
@@ -43,3 +43,20 @@ bool3 test_isinf_float3(float3 p0) { return isinf(p0); }
 // CHECK: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32
 // CHECK: ret <4 x i1> %dx.isinf
 bool4 test_isinf_float4(float4 p0) { return isinf(p0); }
+
+// CHECK: define noundef i1 @
+// CHECK: %dx.isinf = call i1 @llvm.dx.isinf.f32(
+// CHECK: ret i1 %dx.isinf
+bool test_isinf_double(double p0) { return isinf(p0); }
+// CHECK: define noundef <2 x i1> @
+// CHECK: %dx.isinf = call <2 x i1> @llvm.dx.isinf.v2f32
+// CHECK: ret <2 x i1> %dx.isinf
+bool2 test_isinf_double2(double2 p0) { return isinf(p0); }
+// CHECK: define noundef <3 x i1> @
+// CHECK: %dx.isinf = call <3 x i1> @llvm.dx.isinf.v3f32
+// CHECK: ret <3 x i1> %dx.isinf
+bool3 test_isinf_double3(double3 p0) { return isinf(p0); }
+// CHECK: define noundef <4 x i1> @
+// CHECK: %dx.isinf = call <4 x i1> @llvm.dx.isinf.v4f32
+// CHECK: ret <4 x i1> %dx.isinf
+bool4 test_isinf_double4(double4 p0) { return isinf(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/lerp.hlsl 
b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
index d7a7113de4878..4e81d72e7fa9f 100644
--- a/clang/test/CodeGenHLSL/builtins/lerp.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/lerp.hlsl
@@ -56,3 +56,23 @@ float3 test_lerp_float3(float3 p0) { return lerp(p0, p0, 
p0); }
 // CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
 // CHECK: ret <4 x float> %hlsl.lerp
 float4 test_lerp_float4(float4 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_double
+// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].lerp.f32(float %{{.*}}, float %{{.*}}, float %{{.*}})
+// CHECK: ret float %hlsl.lerp
+float test_lerp_double(double p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_double2
+// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].lerp.v2f32(<2 x float> %{{.*}}, <2 x float> %{{.*}}, <2 x 
float> %{{.*}})
+// CHECK: ret <2 x float> %hlsl.lerp
+float2 test_lerp_double2(double2 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_double3
+// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].lerp.v3f32(<3 x float> %{{.*}}, <3 x float> %{{.*}}, <3 x 
float> %{{.*}})
+// CHECK: ret <3 x float> %hlsl.lerp
+float3 test_lerp_double3(double3 p0) { return lerp(p0, p0, p0); }
+
+// CHECK-LABEL: test_lerp_double4
+// CHECK: %hlsl.lerp = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].lerp.v4f32(<4 x float> %{{.*}}, <4 x float> %{{.*}}, <4 x 
float> %{{.*}})
+// CHECK: ret <4 x float> %hlsl.lerp
+float4 test_lerp_double4(double4 p0) { return lerp(p0, p0, p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/log.hlsl 
b/clang/test/CodeGenHLSL/builtins/log.hlsl
index e489939594a53..3b44a74c72355 100644
--- a/clang/test/CodeGenHLSL/builtins/log.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log.hlsl
@@ -38,3 +38,16 @@ float3 test_log_float3(float3 p0) { return log(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z15test_log_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log.v4f32
 float4 test_log_float4(float4 p0) { return log(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_log_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.log.f32(
+float test_log_double(double p0) { return log(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_log_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.log.v2f32
+float2 test_log_double2(double2 p0) { return log(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_log_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.log.v3f32
+float3 test_log_double3(double3 p0) { return log(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_log_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log.v4f32
+float4 test_log_double4(double4 p0) { return log(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/log10.hlsl 
b/clang/test/CodeGenHLSL/builtins/log10.hlsl
index 37c8e837c45a3..a5e77153f53b0 100644
--- a/clang/test/CodeGenHLSL/builtins/log10.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log10.hlsl
@@ -38,3 +38,16 @@ float3 test_log10_float3(float3 p0) { return log10(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z17test_log10_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log10.v4f32
 float4 test_log10_float4(float4 p0) { return log10(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_log10_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.log10.f32(
+float test_log10_double(double p0) { return log10(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_log10_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.log10.v2f32
+float2 test_log10_double2(double2 p0) { return log10(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_log10_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.log10.v3f32
+float3 test_log10_double3(double3 p0) { return log10(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_log10_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log10.v4f32
+float4 test_log10_double4(double4 p0) { return log10(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/log2.hlsl 
b/clang/test/CodeGenHLSL/builtins/log2.hlsl
index 5159d5bb0fa4e..9af346289f8dc 100644
--- a/clang/test/CodeGenHLSL/builtins/log2.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/log2.hlsl
@@ -38,3 +38,16 @@ float3 test_log2_float3(float3 p0) { return log2(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z16test_log2_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log2.v4f32
 float4 test_log2_float4(float4 p0) { return log2(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_log2_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.log2.f32(
+float test_log2_double(double p0) { return log2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_log2_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.log2.v2f32
+float2 test_log2_double2(double2 p0) { return log2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_log2_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.log2.v3f32
+float3 test_log2_double3(double3 p0) { return log2(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_log2_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.log2.v4f32
+float4 test_log2_double4(double4 p0) { return log2(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/normalize.hlsl 
b/clang/test/CodeGenHLSL/builtins/normalize.hlsl
index 830fc26b7acf0..d17ab4fd09a13 100644
--- a/clang/test/CodeGenHLSL/builtins/normalize.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/normalize.hlsl
@@ -83,3 +83,33 @@ float4 test_length_float4(float4 p0)
 {
     return normalize(p0);
 }
+
+// CHECK: define [[FNATTRS]] float @
+// CHECK: call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].normalize.f32(float
+// CHECK: ret float
+float test_normalize_double(double p0)
+{
+    return normalize(p0);
+}
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %hlsl.normalize = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].normalize.v2f32(<2 x float>
+
+// CHECK: ret <2 x float> %hlsl.normalize
+float2 test_normalize_double2(double2 p0)
+{
+    return normalize(p0);
+}
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %hlsl.normalize = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].normalize.v3f32(
+// CHECK: ret <3 x float> %hlsl.normalize
+float3 test_normalize_double3(double3 p0)
+{
+    return normalize(p0);
+}
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %hlsl.normalize = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].normalize.v4f32(
+// CHECK: ret <4 x float> %hlsl.normalize
+float4 test_length_double4(double4 p0)
+{
+    return normalize(p0);
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/pow.hlsl 
b/clang/test/CodeGenHLSL/builtins/pow.hlsl
index fd21f1b94c57e..b8b9c68698237 100644
--- a/clang/test/CodeGenHLSL/builtins/pow.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/pow.hlsl
@@ -38,3 +38,16 @@ float3 test_pow_float3(float3 p0, float3 p1) { return 
pow(p0, p1); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z15test_pow_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.pow.v4f32
 float4 test_pow_float4(float4 p0, float4 p1) { return pow(p0, p1); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_pow_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.pow.f32(
+float test_pow_double(double p0, double p1) { return pow(p0, p1); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_pow_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.pow.v2f32
+float2 test_pow_double2(double2 p0, double2 p1) { return pow(p0, p1); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_pow_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.pow.v3f32
+float3 test_pow_double3(double3 p0, double3 p1) { return pow(p0, p1); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_pow_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.pow.v4f32
+float4 test_pow_double4(double4 p0, double4 p1) { return pow(p0, p1); }

diff  --git a/clang/test/CodeGenHLSL/builtins/radians.hlsl 
b/clang/test/CodeGenHLSL/builtins/radians.hlsl
index b2b6190ea90f6..0cc5d24f921af 100644
--- a/clang/test/CodeGenHLSL/builtins/radians.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/radians.hlsl
@@ -64,3 +64,19 @@ float3 test_radians_float3(float3 p0) { return radians(p0); }
 // CHECK: ret <4 x float> %{{.*}}
 float4 test_radians_float4(float4 p0) { return radians(p0); }
 
+// CHECK: define [[FNATTRS]] float @
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].radians.f32(
+// CHECK: ret float %{{.*}}
+float test_radians_double(double p0) { return radians(p0); }
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].radians.v2f32
+// CHECK: ret <2 x float> %{{.*}}
+float2 test_radians_double2(double2 p0) { return radians(p0); }
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].radians.v3f32
+// CHECK: ret <3 x float> %{{.*}}
+float3 test_radians_double3(double3 p0) { return radians(p0); }
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].radians.v4f32
+// CHECK: ret <4 x float> %{{.*}}
+float4 test_radians_double4(double4 p0) { return radians(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/round.hlsl 
b/clang/test/CodeGenHLSL/builtins/round.hlsl
index a945a9677abbb..a2c00c8cb36fc 100644
--- a/clang/test/CodeGenHLSL/builtins/round.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/round.hlsl
@@ -50,3 +50,20 @@ float3 test_round_float3(float3 p0) { return round(p0); }
 // CHECK: %elt.roundeven = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.roundeven.v4f32
 // CHECK: ret <4 x float> %elt.roundeven
 float4 test_round_float4(float4 p0) { return round(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_round_double
+// CHECK: %elt.roundeven = call reassoc nnan ninf nsz arcp afn float 
@llvm.roundeven.f32(
+// CHECK: ret float %elt.roundeven
+float test_round_double(double p0) { return round(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_round_double2
+// CHECK: %elt.roundeven = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.roundeven.v2f32
+// CHECK: ret <2 x float> %elt.roundeven
+float2 test_round_double2(double2 p0) { return round(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_round_double3
+// CHECK: %elt.roundeven = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.roundeven.v3f32
+// CHECK: ret <3 x float> %elt.roundeven
+float3 test_round_double3(double3 p0) { return round(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_round_double4
+// CHECK: %elt.roundeven = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.roundeven.v4f32
+// CHECK: ret <4 x float> %elt.roundeven
+float4 test_round_double4(double4 p0) { return round(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl 
b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
index 6c9b1f643713b..512bb6170a491 100644
--- a/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/rsqrt.hlsl
@@ -62,3 +62,20 @@ float3 test_rsqrt_float3(float3 p0) { return rsqrt(p0); }
 // CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].rsqrt.v4f32
 // CHECK: ret <4 x float> %hlsl.rsqrt
 float4 test_rsqrt_float4(float4 p0) { return rsqrt(p0); }
+
+// CHECK: define [[FNATTRS]] float @
+// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].rsqrt.f32(
+// CHECK: ret float %hlsl.rsqrt
+float test_rsqrt_double(double p0) { return rsqrt(p0); }
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].rsqrt.v2f32
+// CHECK: ret <2 x float> %hlsl.rsqrt
+float2 test_rsqrt_double2(double2 p0) { return rsqrt(p0); }
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].rsqrt.v3f32
+// CHECK: ret <3 x float> %hlsl.rsqrt
+float3 test_rsqrt_double3(double3 p0) { return rsqrt(p0); }
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %hlsl.rsqrt = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].rsqrt.v4f32
+// CHECK: ret <4 x float> %hlsl.rsqrt
+float4 test_rsqrt_double4(double4 p0) { return rsqrt(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/sin.hlsl 
b/clang/test/CodeGenHLSL/builtins/sin.hlsl
index 69c657239ef95..fc44f35f838a9 100644
--- a/clang/test/CodeGenHLSL/builtins/sin.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sin.hlsl
@@ -38,3 +38,16 @@ float3 test_sin_float3(float3 p0) { return sin(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z15test_sin_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.sin.v4f32
 float4 test_sin_float4(float4 p0) { return sin(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_sin_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.sin.f32(
+float test_sin_double(double p0) { return sin(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_sin_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.sin.v2f32
+float2 test_sin_double2(double2 p0) { return sin(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_sin_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.sin.v3f32
+float3 test_sin_double3(double3 p0) { return sin(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_sin_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.sin.v4f32
+float4 test_sin_double4(double4 p0) { return sin(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/sinh.hlsl 
b/clang/test/CodeGenHLSL/builtins/sinh.hlsl
index d55d60515418c..2850877180a4e 100644
--- a/clang/test/CodeGenHLSL/builtins/sinh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sinh.hlsl
@@ -57,3 +57,27 @@ float3 test_sinh_float3 ( float3 p0 ) {
 float4 test_sinh_float4 ( float4 p0 ) {
   return sinh ( p0 );
 }
+
+// CHECK-LABEL: test_sinh_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.sinh.f32
+float test_sinh_double ( double p0 ) {
+  return sinh ( p0 );
+}
+
+// CHECK-LABEL: test_sinh_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.sinh.v2f32
+float2 test_sinh_double2 ( double2 p0 ) {
+  return sinh ( p0 );
+}
+
+// CHECK-LABEL: test_sinh_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.sinh.v3f32
+float3 test_sinh_double3 ( double3 p0 ) {
+  return sinh ( p0 );
+}
+
+// CHECK-LABEL: test_sinh_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.sinh.v4f32
+float4 test_sinh_double4 ( double4 p0 ) {
+  return sinh ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl 
b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
index 94d966f0bef8a..cda6df9a5bb7a 100644
--- a/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/sqrt.hlsl
@@ -50,3 +50,20 @@ float3 test_sqrt_float3(float3 p0) { return sqrt(p0); }
 // CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.sqrt.v4f32
 // CHECK: ret <4 x float> %{{.*}}
 float4 test_sqrt_float4(float4 p0) { return sqrt(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_sqrt_double
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn float @llvm.sqrt.f32(
+// CHECK: ret float %{{.*}}
+float test_sqrt_double(double p0) { return sqrt(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_sqrt_double2
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.sqrt.v2f32
+// CHECK: ret <2 x float> %{{.*}}
+float2 test_sqrt_double2(double2 p0) { return sqrt(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_sqrt_double3
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.sqrt.v3f32
+// CHECK: ret <3 x float> %{{.*}}
+float3 test_sqrt_double3(double3 p0) { return sqrt(p0); }
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_sqrt_double4
+// CHECK: %{{.*}} = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.sqrt.v4f32
+// CHECK: ret <4 x float> %{{.*}}
+float4 test_sqrt_double4(double4 p0) { return sqrt(p0); }

diff  --git a/clang/test/CodeGenHLSL/builtins/step.hlsl 
b/clang/test/CodeGenHLSL/builtins/step.hlsl
index 49d09e5c6fe6f..1494f284aa6f5 100644
--- a/clang/test/CodeGenHLSL/builtins/step.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/step.hlsl
@@ -82,3 +82,32 @@ float4 test_step_float4(float4 p0, float4 p1)
 {
     return step(p0, p1);
 }
+
+// CHECK: define [[FNATTRS]] float @
+// CHECK: call reassoc nnan ninf nsz arcp afn float 
@llvm.[[TARGET]].step.f32(float
+// CHECK: ret float
+float test_step_double(double p0, double p1)
+{
+    return step(p0, p1);
+}
+// CHECK: define [[FNATTRS]] <2 x float> @
+// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <2 x float> 
@llvm.[[TARGET]].step.v2f32(
+// CHECK: ret <2 x float> %hlsl.step
+float2 test_step_double2(double2 p0, double2 p1)
+{
+    return step(p0, p1);
+}
+// CHECK: define [[FNATTRS]] <3 x float> @
+// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <3 x float> 
@llvm.[[TARGET]].step.v3f32(
+// CHECK: ret <3 x float> %hlsl.step
+float3 test_step_double3(double3 p0, double3 p1)
+{
+    return step(p0, p1);
+}
+// CHECK: define [[FNATTRS]] <4 x float> @
+// CHECK: %hlsl.step = call reassoc nnan ninf nsz arcp afn <4 x float> 
@llvm.[[TARGET]].step.v4f32(
+// CHECK: ret <4 x float> %hlsl.step
+float4 test_step_double4(double4 p0, double4 p1)
+{
+    return step(p0, p1);
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/tan.hlsl 
b/clang/test/CodeGenHLSL/builtins/tan.hlsl
index c8c948624a613..3cc7d00508397 100644
--- a/clang/test/CodeGenHLSL/builtins/tan.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tan.hlsl
@@ -57,3 +57,27 @@ float3 test_tan_float3 ( float3 p0 ) {
 float4 test_tan_float4 ( float4 p0 ) {
   return tan ( p0 );
 }
+
+// CHECK-LABEL: test_tan_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.tan.f32
+float test_tan_double ( double p0 ) {
+  return tan ( p0 );
+}
+
+// CHECK-LABEL: test_tan_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.tan.v2f32
+float2 test_tan_double2 ( double2 p0 ) {
+  return tan ( p0 );
+}
+
+// CHECK-LABEL: test_tan_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.tan.v3f32
+float3 test_tan_double3 ( double3 p0 ) {
+  return tan ( p0 );
+}
+
+// CHECK-LABEL: test_tan_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.tan.v4f32
+float4 test_tan_double4 ( double4 p0 ) {
+  return tan ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/tanh.hlsl 
b/clang/test/CodeGenHLSL/builtins/tanh.hlsl
index f947c7f53b110..4f34a38bbf9ae 100644
--- a/clang/test/CodeGenHLSL/builtins/tanh.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/tanh.hlsl
@@ -57,3 +57,27 @@ float3 test_tanh_float3 ( float3 p0 ) {
 float4 test_tanh_float4 ( float4 p0 ) {
   return tanh ( p0 );
 }
+
+// CHECK-LABEL: test_tanh_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.tanh.f32
+float test_tanh_double ( double p0 ) {
+  return tanh ( p0 );
+}
+
+// CHECK-LABEL: test_tanh_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.tanh.v2f32
+float2 test_tanh_double2 ( double2 p0 ) {
+  return tanh ( p0 );
+}
+
+// CHECK-LABEL: test_tanh_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.tanh.v3f32
+float3 test_tanh_double3 ( double3 p0 ) {
+  return tanh ( p0 );
+}
+
+// CHECK-LABEL: test_tanh_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.tanh.v4f32
+float4 test_tanh_double4 ( double4 p0 ) {
+  return tanh ( p0 );
+}

diff  --git a/clang/test/CodeGenHLSL/builtins/trunc.hlsl 
b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
index 26de5bf94c3cc..66bd165cbd370 100644
--- a/clang/test/CodeGenHLSL/builtins/trunc.hlsl
+++ b/clang/test/CodeGenHLSL/builtins/trunc.hlsl
@@ -44,3 +44,19 @@ float3 test_trunc_float3(float3 p0) { return trunc(p0); }
 // CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
@_Z17test_trunc_float4
 // CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.trunc.v4f32
 float4 test_trunc_float4(float4 p0) { return trunc(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) float {{.*}}test_trunc_double
+// CHECK: call reassoc nnan ninf nsz arcp afn float @llvm.trunc.f32(
+float test_trunc_double(double p0) { return trunc(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <2 x float> 
{{.*}}test_trunc_double2
+// CHECK: call reassoc nnan ninf nsz arcp afn <2 x float> @llvm.trunc.v2f32
+float2 test_trunc_double2(double2 p0) { return trunc(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <3 x float> 
{{.*}}test_trunc_double3
+// CHECK: call reassoc nnan ninf nsz arcp afn <3 x float> @llvm.trunc.v3f32
+float3 test_trunc_double3(double3 p0) { return trunc(p0); }
+
+// CHECK-LABEL: define noundef nofpclass(nan inf) <4 x float> 
{{.*}}test_trunc_double4
+// CHECK: call reassoc nnan ninf nsz arcp afn <4 x float> @llvm.trunc.v4f32
+float4 test_trunc_double4(double4 p0) { return trunc(p0); }


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to