Skip to content

Commit c5eaad0

Browse files
authored
[SYCLomatic] Fix the migration of tanhf (#2709)
Signed-off-by: Jiang, Zhiwei <zhiwei.jiang@intel.com>
1 parent dec64d6 commit c5eaad0

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

clang/lib/DPCT/RuleInfra/CallExprRewriterCommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ template <class SubExprT> class CastIfNotSameExprPrinter {
145145
: TypeInfo(std::forward<std::string>(T)),
146146
SubExpr(std::forward<SubExprT>(S)) {}
147147
template <class StreamT> void print(StreamT &Stream) const {
148-
const Expr *InputArg = SubExpr->IgnoreImpCasts();
148+
const Expr *InputArg = SubExpr->IgnoreUnlessSpelledInSource();
149149
clang::QualType ArgType = InputArg->getType().getCanonicalType();
150150
ArgType.removeLocalFastQualifiers(clang::Qualifiers::CVRMask);
151151
if (ArgType.getAsString() != TypeInfo) {

clang/lib/DPCT/RulesLang/APINamesMath.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ ENTRY_RENAMED_SINGLE("sinhf", MapNames::getClNamespace(false, true) + "sinh")
104104
ENTRY_REWRITE("sinpif")
105105
ENTRY_RENAMED_SINGLE("sqrtf", MapNames::getClNamespace(false, true) + "sqrt")
106106
ENTRY_RENAMED_SINGLE("tanf", MapNames::getClNamespace(false, true) + "tan")
107-
ENTRY_RENAMED_SINGLE("tanhf", MapNames::getClNamespace(false, true) + "tanh")
107+
ENTRY_REWRITE("tanhf")
108108
ENTRY_RENAMED_SINGLE("tgammaf", MapNames::getClNamespace(false, true) + "tgamma")
109109
ENTRY_RENAMED_SINGLE("truncf", MapNames::getClNamespace(false, true) + "trunc")
110110

clang/lib/DPCT/RulesLang/Math/RewriterSinglePrecisionMathematicalFunctions.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,21 @@ RewriterMap dpct::createSinglePrecisionMathematicalFunctionsRewriterMap() {
295295
"sinpif",
296296
CALL(MapNames::getClNamespace() + "sinpi",
297297
CAST_IF_NOT_SAME(makeLiteral("float"), ARG(0))))))
298+
// tanhf
299+
MATH_API_REWRITERS_V2(
300+
"tanhf",
301+
MATH_API_REWRITER_PAIR(
302+
math::Tag::host_normal,
303+
CALL_FACTORY_ENTRY(
304+
"tanhf",
305+
CALL(MapNames::getClNamespace() + "tanh",
306+
CAST_IF_NOT_SAME(makeLiteral("float"), ARG(0))))),
307+
MATH_API_REWRITER_PAIR(
308+
math::Tag::device_normal,
309+
CALL_FACTORY_ENTRY(
310+
"tanhf",
311+
CALL(MapNames::getClNamespace() + "tanh",
312+
CAST_IF_NOT_SAME(makeLiteral("float"), ARG(0))))))
298313
// y0f
299314
MATH_API_REWRITER_DEVICE(
300315
"y0f",

clang/test/dpct/math/cuda-math-intrinsics-cuda8.0-not-support.cu

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,16 @@ __global__ void kernelFuncHalf2() {
2626
h2_2 = __h2div(h2, h2_1);
2727
}
2828

29+
template <typename T> __global__ void foo1(T x) {
30+
// CHECK: T t = (T)sycl::tanh((float)x);
31+
T t = (T)tanhf(x);
32+
}
33+
34+
void foo2() {
35+
float f;
36+
half h;
37+
foo1<<<1, 1>>>(f);
38+
foo1<<<1, 1>>>(h);
39+
}
40+
2941
int main() { return 0; }

0 commit comments

Comments
 (0)