Skip to content

Commit 152f1c8

Browse files
committed
Addressed feedback: No longer checking type in CG: it's already checked in sema; Added radians to half and float only test
1 parent a3d2541 commit 152f1c8

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18894,11 +18894,12 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1889418894
}
1889518895
case Builtin::BI__builtin_hlsl_elementwise_radians: {
1889618896
Value *Op0 = EmitScalarExpr(E->getArg(0));
18897-
if (!E->getArg(0)->getType()->hasFloatingRepresentation())
18898-
llvm_unreachable("radians operand must have a float representation");
18897+
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
18898+
"radians operand must have a float representation");
1889918899
return Builder.CreateIntrinsic(
18900-
/*ReturnType=*/Op0->getType(), CGM.getHLSLRuntime().getRadiansIntrinsic(),
18901-
ArrayRef<Value *>{Op0}, nullptr, "hlsl.radians");
18900+
/*ReturnType=*/Op0->getType(),
18901+
CGM.getHLSLRuntime().getRadiansIntrinsic(), ArrayRef<Value *>{Op0},
18902+
nullptr, "hlsl.radians");
1890218903
}
1890318904
}
1890418905
return nullptr;

clang/test/SemaHLSL/BuiltIns/half-float-only-errors.hlsl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_tan
1818
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_tanh
1919
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_trunc
20+
// RUN: %clang_cc1 -finclude-default-header -triple dxil-pc-shadermodel6.6-library %s -fnative-half-type -emit-llvm-only -disable-llvm-passes -verify -DTEST_FUNC=__builtin_elementwise_radians
2021

2122
double test_double_builtin(double p0) {
2223
return TEST_FUNC(p0);

0 commit comments

Comments
 (0)