-
Notifications
You must be signed in to change notification settings - Fork 14.9k
[Clang] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - add MMX/SSE/AVX/AVX512 PMULHRSW intrinsics to be used in constexpr #160636
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 2 commits
5114dec
8b38951
b8311d2
412712f
125542b
b206462
d91a352
84155ce
59d447d
7b7338f
2be8011
e06361b
86b6eae
c0b7fc1
957b350
c1d1417
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 |
---|---|---|
|
@@ -3311,6 +3311,20 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, | |
return LHS.isSigned() ? LHS.ssub_sat(RHS) : LHS.usub_sat(RHS); | ||
}); | ||
|
||
|
||
case clang::X86::BI__builtin_ia32_pmulhrsw128: | ||
case clang::X86::BI__builtin_ia32_pmulhrsw256: | ||
case clang::X86::BI__builtin_ia32_pmulhrsw512: | ||
return interp__builtin_elementwise_int_binop( | ||
S, OpPC, Call, BuiltinID,[](const APSInt &LHS, const APSInt &RHS) { | ||
unsigned width = LHS.getBitWidth(); | ||
|
||
|
||
Temperz87 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
APInt mul = llvm::APIntOps::mulhs(LHS, RHS); | ||
mul = mul.relativeLShr(14); | ||
mul = mul.sadd_sat(APInt(width, 1, true)); | ||
return APInt(mul.relativeLShr(1)); | ||
}); | ||
|
||
case clang::X86::BI__builtin_ia32_pmulhuw128: | ||
case clang::X86::BI__builtin_ia32_pmulhuw256: | ||
case clang::X86::BI__builtin_ia32_pmulhuw512: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1375,6 +1375,8 @@ __m512i test_mm512_mulhrs_epi16(__m512i __A, __m512i __B) { | |
// CHECK: @llvm.x86.avx512.pmul.hr.sw.512 | ||
return _mm512_mulhrs_epi16(__A,__B); | ||
} | ||
TEST_CONSTEXPR(match_v32hi(_mm512_mulhrs_epi16((__m512i)(__v32hi){+1, -2, +3, -4, +5, -6, +7, -8, +9, -10, +11, -12, +13, -14, +15, -16, +17, -18, +19, -20, +21, -22, +23, -24, +25, -26, +27, -28, +29, -30, +31, -32}, (__m512i)(__v32hi){-64, -62, +60, +58, -56, -54, +52, +50, -48, -46, +44, +42, -40, -38, +36, +34, -32, -30, +28, +26, -24, -22, +20, +18, -16, -14, +12, +10, -8, +6, -4, +2}), 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 0, 0, 2, 2, 2, 2, 2)); | ||
|
||
|
||
__m512i test_mm512_mask_mulhrs_epi16(__m512i __W, __mmask32 __U, __m512i __A, __m512i __B) { | ||
// CHECK-LABEL: test_mm512_mask_mulhrs_epi16 | ||
// CHECK: @llvm.x86.avx512.pmul.hr.sw.512 | ||
|
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.
move this with pmulhuw512 etc. below instead of creating a new block?