Skip to content

Commit c11f91a

Browse files
authored
[clang] Fix ignoring converted first arg of elementwise_fma (#154941)
Fixes #154900
1 parent 6f9bce9 commit c11f91a

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

clang/lib/Sema/SemaChecking.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15955,6 +15955,7 @@ bool Sema::BuiltinElementwiseTernaryMath(
1595515955
return true;
1595615956
}
1595715957

15958+
TheCall->setArg(0, Args[0]);
1595815959
for (int I = 1; I < 3; ++I) {
1595915960
if (Args[0]->getType().getCanonicalType() !=
1596015961
Args[I]->getType().getCanonicalType()) {

clang/test/Sema/constant-builtins-vector.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,3 +957,7 @@ static_assert(fmaDouble1[0] == 5.0);
957957
static_assert(fmaDouble1[1] == 10.0);
958958
static_assert(fmaDouble1[2] == 17.0);
959959
static_assert(fmaDouble1[3] == 26.0);
960+
961+
constexpr float fmaArray[] = {2.0f, 2.0f, 2.0f, 2.0f};
962+
constexpr float fmaResult = __builtin_elementwise_fma(fmaArray[1], fmaArray[2], fmaArray[3]);
963+
static_assert(fmaResult == 6.0f, "");

0 commit comments

Comments
 (0)