Skip to content

Commit 37091d1

Browse files
committed
address pr comments
1 parent 080b65f commit 37091d1

File tree

5 files changed

+51
-29
lines changed

5 files changed

+51
-29
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17976,17 +17976,15 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned BuiltinID,
1797617976
llvm::Type *T0 = Op0->getType();
1797717977
llvm::Type *T1 = Op1->getType();
1797817978
if (!T0->isVectorTy() && !T1->isVectorTy()) {
17979-
if (T0->isFloatingPointTy()) {
17979+
if (T0->isFloatingPointTy())
1798017980
return Builder.CreateFMul(Op0, Op1, "dx.dot");
17981-
}
1798217981

17983-
if (T0->isIntegerTy()) {
17982+
if (T0->isIntegerTy())
1798417983
return Builder.CreateMul(Op0, Op1, "dx.dot");
17985-
}
17984+
1798617985
// Bools should have been promoted
17987-
assert(
17988-
false &&
17989-
"Dot product on a scalar is only supported on integers and floats.");
17986+
llvm_unreachable(
17987+
"Scalar dot product is only supported on ints and floats.");
1799017988
}
1799117989
// A VectorSplat should have happened
1799217990
assert(T0->isVectorTy() && T1->isVectorTy() &&

clang/test/CodeGenHLSL/builtins/dot.hlsl

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
// RUN: dxil-pc-shadermodel6.3-library %s -emit-llvm -disable-llvm-passes \
77
// RUN: -o - | FileCheck %s --check-prefixes=CHECK,NO_HALF
88

9-
// -fnative-half-type sets __HLSL_ENABLE_16_BIT
109
#ifdef __HLSL_ENABLE_16_BIT
1110
// NATIVE_HALF: %dx.dot = mul i16 %0, %1
1211
// NATIVE_HALF: ret i16 %dx.dot
@@ -113,19 +112,19 @@ int64_t test_dot_long ( int64_t p0, int64_t p1 ) {
113112

114113
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v2i64(<2 x i64> %0, <2 x i64> %1)
115114
// CHECK: ret i64 %dx.dot
116-
int64_t test_dot_uint2 ( int64_t2 p0, int64_t2 p1 ) {
115+
int64_t test_dot_long2 ( int64_t2 p0, int64_t2 p1 ) {
117116
return dot ( p0, p1 );
118117
}
119118

120119
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v3i64(<3 x i64> %0, <3 x i64> %1)
121120
// CHECK: ret i64 %dx.dot
122-
int64_t test_dot_uint3 ( int64_t3 p0, int64_t3 p1 ) {
121+
int64_t test_dot_long3 ( int64_t3 p0, int64_t3 p1 ) {
123122
return dot ( p0, p1 );
124123
}
125124

126125
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v4i64(<4 x i64> %0, <4 x i64> %1)
127126
// CHECK: ret i64 %dx.dot
128-
int64_t test_dot_uint4 ( int64_t4 p0, int64_t4 p1 ) {
127+
int64_t test_dot_long4 ( int64_t4 p0, int64_t4 p1 ) {
129128
return dot ( p0, p1 );
130129
}
131130

@@ -137,19 +136,19 @@ uint64_t test_dot_ulong ( uint64_t p0, uint64_t p1 ) {
137136

138137
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v2i64(<2 x i64> %0, <2 x i64> %1)
139138
// CHECK: ret i64 %dx.dot
140-
uint64_t test_dot_uint2 ( uint64_t2 p0, uint64_t2 p1 ) {
139+
uint64_t test_dot_ulong2 ( uint64_t2 p0, uint64_t2 p1 ) {
141140
return dot ( p0, p1 );
142141
}
143142

144143
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v3i64(<3 x i64> %0, <3 x i64> %1)
145144
// CHECK: ret i64 %dx.dot
146-
uint64_t test_dot_uint3 ( uint64_t3 p0, uint64_t3 p1 ) {
145+
uint64_t test_dot_ulong3 ( uint64_t3 p0, uint64_t3 p1 ) {
147146
return dot ( p0, p1 );
148147
}
149148

150149
// CHECK: %dx.dot = call i64 @llvm.dx.dot.v4i64(<4 x i64> %0, <4 x i64> %1)
151150
// CHECK: ret i64 %dx.dot
152-
uint64_t test_dot_uint4 ( uint64_t4 p0, uint64_t4 p1 ) {
151+
uint64_t test_dot_ulong4 ( uint64_t4 p0, uint64_t4 p1 ) {
153152
return dot ( p0, p1 );
154153
}
155154

clang/test/SemaHLSL/BuiltIns/dot-errors.hlsl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ float test_too_many_arg ( float2 p0) {
1010
// expected-error@-1 {{too many arguments to function call, expected 2, have 3}}
1111
}
1212

13-
//NOTE: eventually behavior should match builtin
1413
float test_dot_no_second_arg ( float2 p0) {
1514
return dot ( p0 );
1615
// expected-error@-1 {{no matching function for call to 'dot'}}

clang/test/SemaHLSL/BuiltIns/dot-warning.hlsl

Lines changed: 0 additions & 14 deletions
This file was deleted.

clang/test/SemaHLSL/OverloadResolutionBugs.hlsl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,46 @@ void Call4(int16_t H) {
2424
Fn4(H);
2525
}
2626

27+
int test_builtin_dot_bool_type_promotion ( bool p0, bool p1 ) {
28+
return dot ( p0, p1 );
29+
}
30+
31+
float test_dot_scalar_mismatch ( float p0, int p1 ) {
32+
return dot ( p0, p1 );
33+
}
34+
35+
float test_dot_element_type_mismatch ( int2 p0, float2 p1 ) {
36+
return dot ( p0, p1 );
37+
}
38+
39+
float test_builtin_dot_vec_int_to_float_promotion ( int2 p0, float2 p1 ) {
40+
return dot ( p0, p1 );
41+
}
42+
43+
int64_t test_builtin_dot_vec_int_to_int64_promotion( int64_t2 p0, int2 p1 ) {
44+
return dot ( p0, p1 );
45+
}
46+
47+
float test_builtin_dot_vec_half_to_float_promotion( float2 p0, half2 p1 ) {
48+
return dot( p0, p1 );
49+
}
50+
51+
float test_builtin_dot_vec_int16_to_float_promotion( float2 p0, int16_t2 p1 ) {
52+
return dot( p0, p1 );
53+
}
54+
55+
half test_builtin_dot_vec_int16_to_half_promotion( half2 p0, int16_t2 p1 ) {
56+
return dot( p0, p1 );
57+
}
58+
59+
int test_builtin_dot_vec_int16_to_int_promotion( int2 p0, int16_t2 p1 ) {
60+
return dot( p0, p1 );
61+
}
62+
63+
int64_t test_builtin_dot_vec_int16_to_int64_promotion( int64_t2 p0, int16_t2 p1 ) {
64+
return dot( p0, p1 );
65+
}
66+
2767
// https://github.com/llvm/llvm-project/issues/81049
2868

2969
// RUN: %clang_cc1 -std=hlsl2021 -finclude-default-header -x hlsl -triple \

0 commit comments

Comments
 (0)