-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Headers][X86] Enable constexpr handling for MMX/SSE/AVX/AVX512 PMADDWD/PMADDUBSW intrinsics #161563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
4300c53
to
4283909
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing test coverage in sse2-builtins.c etc.
case clang::X86::BI__builtin_ia32_pmaddubsw128: | ||
case clang::X86::BI__builtin_ia32_pmaddubsw256: | ||
case clang::X86::BI__builtin_ia32_pmaddubsw512: | ||
return interp__builtin_ia32_pmadd(S, OpPC, Call, BuiltinID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a callback system like interp__builtin_elementwise_int_binop:
return interp__builtin_ia32_pmadd(S, OpPC, Call,
[](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &HiRHS, const APSInt &HiRHS) {
unsigned BitWidth = 2 * LHS.getBitWidth();
return (LoLHS.zext(BitWidth) * LoRHS.sext(BitWidth)).sadd_sat((HiLHS.zext(BitWidth) * HiRHS.sext(BitWidth)));
});
case clang::X86::BI__builtin_ia32_pmaddwd128: | ||
case clang::X86::BI__builtin_ia32_pmaddwd256: | ||
case clang::X86::BI__builtin_ia32_pmaddwd512: | ||
return interp__builtin_ia32_pmadd(S, OpPC, Call, BuiltinID); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use a callback system like interp__builtin_elementwise_int_binop:
return interp__builtin_ia32_pmadd(S, OpPC, Call,
[](const APSInt &LoLHS, const APSInt &HiLHS, const APSInt &HiRHS, const APSInt &HiRHS) {
unsigned BitWidth = 2 * LHS.getBitWidth();
return (LoLHS.sext(BitWidth) * LoRHS.sext(BitWidth)) + (HiLHS.sext(BitWidth) * HiRHS.sext(BitWidth));
});
case clang::X86::BI__builtin_ia32_pmaddubsw512: | ||
Mul0 = APSInt(U_LHS0.zext(BitWidth) * RHS0.sext(BitWidth)); | ||
Mul1 = APSInt(U_LHS1.zext(BitWidth) * RHS1.sext(BitWidth)); | ||
Result = APSInt(Mul0.sadd_sat(Mul1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing signedness control:
bool DestUnsigned = Call->getType()->isUnsignedIntegerOrEnumerationType();
Result = APSInt(..., DestUnsigned);
case clang::X86::BI__builtin_ia32_pmaddwd512: | ||
Mul0 = APSInt(LHS0.sext(BitWidth) * RHS0.sext(BitWidth)); | ||
Mul1 = APSInt(LHS1.sext(BitWidth) * RHS1.sext(BitWidth)); | ||
Result = APSInt(Mul0 + Mul1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing signedness control
clang/lib/AST/ExprConstant.cpp
Outdated
case clang::X86::BI__builtin_ia32_pmaddwd512: | ||
ResultElements.push_back( | ||
APValue(APSInt(LHS0.sext(BitWidth) * RHS0.sext(BitWidth) + | ||
LHS1.sext(BitWidth) * RHS1.sext(BitWidth)))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing signedness control
clang/lib/AST/ExprConstant.cpp
Outdated
ResultElements.push_back(APValue( | ||
APSInt(APInt(U_LHS0.zext(BitWidth)) * | ||
RHS0.sext(BitWidth).sadd_sat(APInt(U_LHS1.zext(BitWidth)) * | ||
RHS1.sext(BitWidth))))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing signedness control
4283909
to
850c536
Compare
I'm working on it. Sorry for taking such a long time on the issue. 😅 |
…WD/PMADDUBSW intrinsics
850c536
to
6ee2d23
Compare
6ee2d23
to
43a3a27
Compare
This PR updates the PMADDWD/PMADDUBSW builtins to support constant expression handling, by extending the VectorExprEvaluator::VisitCallExpr that handles interp__builtin_ia32_pmadd builtins.
Closes #155392