-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[Headers][X86] Enable constexpr handling for pmulhw/pmulhuw intrinsics #152540
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
Changes from 1 commit
ecf9ae0
a9e0536
504af19
40170b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11628,7 +11628,13 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) { | |
return Success(APValue(ResultElements.data(), ResultElements.size()), E); | ||
} | ||
case Builtin::BI__builtin_elementwise_add_sat: | ||
case Builtin::BI__builtin_elementwise_sub_sat: { | ||
case Builtin::BI__builtin_elementwise_sub_sat: | ||
case clang::X86::BI__builtin_ia32_pmulhuw128: | ||
case clang::X86::BI__builtin_ia32_pmulhuw256: | ||
case clang::X86::BI__builtin_ia32_pmulhuw512: | ||
case clang::X86::BI__builtin_ia32_pmulhw128: | ||
case clang::X86::BI__builtin_ia32_pmulhw256: | ||
case clang::X86::BI__builtin_ia32_pmulhw512: { | ||
APValue SourceLHS, SourceRHS; | ||
if (!EvaluateAsRValue(Info, E->getArg(0), SourceLHS) || | ||
!EvaluateAsRValue(Info, E->getArg(1), SourceRHS)) | ||
|
@@ -11653,6 +11659,18 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) { | |
APSInt(LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS), | ||
DestEltTy->isUnsignedIntegerOrEnumerationType()))); | ||
break; | ||
case clang::X86::BI__builtin_ia32_pmulhuw128: | ||
case clang::X86::BI__builtin_ia32_pmulhuw256: | ||
case clang::X86::BI__builtin_ia32_pmulhuw512: | ||
ResultElements.push_back(APValue(APSInt(llvm::APIntOps::mulhu(LHS, RHS), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the input and output types be unsigned? |
||
/*isUnsigned=*/true))); | ||
break; | ||
case clang::X86::BI__builtin_ia32_pmulhw128: | ||
case clang::X86::BI__builtin_ia32_pmulhw256: | ||
case clang::X86::BI__builtin_ia32_pmulhw512: | ||
ResultElements.push_back(APValue(APSInt(llvm::APIntOps::mulhs(LHS, RHS), | ||
/*isUnsigned=*/false))); | ||
break; | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -365,12 +365,14 @@ __m64 test_mm_mulhi_pi16(__m64 a, __m64 b) { | |
// CHECK: call <8 x i16> @llvm.x86.sse2.pmulh.w( | ||
return _mm_mulhi_pi16(a, b); | ||
} | ||
TEST_CONSTEXPR(match_v4hi(_mm_mulhi_pi16((__m64)(__v4hi){+1, -2, +3, -4}, (__m64)(__v4hi){-10, +8, +6, -4}), -1, -1, 0, 0)); | ||
|
||
__m64 test_mm_mulhi_pu16(__m64 a, __m64 b) { | ||
// CHECK-LABEL: test_mm_mulhi_pu16 | ||
// CHECK: call <8 x i16> @llvm.x86.sse2.pmulhu.w( | ||
return _mm_mulhi_pu16(a, b); | ||
} | ||
TEST_CONSTEXPR(match_v4hi(_mm_mulhi_pu16((__m64)(__v4hi){+1, -2, +3, -4}, (__m64)(__v4hi){-10, +8, +6, -4}), 0, 7, 0, -8)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The result doesn't look correct. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It should be correct (and it matches what DAG constant folding does), what concerns you? Would it be better if I added a match_v4u so we can show as unsigned results? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For example, |
||
|
||
__m64 test_mm_mulhrs_pi16(__m64 a, __m64 b) { | ||
// CHECK-LABEL: test_mm_mulhrs_pi16 | ||
|
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.
Attributes = [NoThrow, Const, Constexpr, RequiredVectorWidth<128>]