-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[Headers][X86] VectorExprEvaluator::VisitCallExpr / InterpretBuiltin - allow PALIGNR byte shift intrinsics to be used in constexpr #162005
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 7 commits
28819c6
4247c75
c70e2c7
fc26847
6d3534e
11ae9f1
a6e870d
2f0b435
e1c5df0
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -4718,6 +4718,30 @@ bool InterpretBuiltin(InterpState &S, CodePtr OpPC, const CallExpr *Call, | |||||
| return APInt(8, 0); | ||||||
| }); | ||||||
|
|
||||||
| case X86::BI__builtin_ia32_palignr128: | ||||||
| case X86::BI__builtin_ia32_palignr256: | ||||||
| case X86::BI__builtin_ia32_palignr512: | ||||||
| return interp__builtin_ia32_shuffle_generic( | ||||||
| S, OpPC, Call, [](unsigned DstIdx, unsigned Shift) { | ||||||
| // Default to -1 → zero-fill this destination element | ||||||
| unsigned VecIdx = 1; | ||||||
| int ElemIdx = -1; | ||||||
|
|
||||||
| int Lane = DstIdx / 16; | ||||||
| int Offset = DstIdx % 16; | ||||||
|
|
||||||
| // Elements come from VecB first, then VecA after the shift boundary | ||||||
| unsigned ShiftedIdx = Offset + Shift; | ||||||
| if (ShiftedIdx < 16) { // from VecB | ||||||
| ElemIdx = ShiftedIdx + Lane * 16; | ||||||
|
||||||
| ElemIdx = ShiftedIdx + Lane * 16; | |
| ElemIdx = ShiftedIdx + (Lane * 16); |
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.
Done, thanks
Outdated
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.
| ElemIdx = ShiftedIdx - 16 + Lane * 16; | |
| ElemIdx = (ShiftedIdx - 16) + (Lane * 16); |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -11665,8 +11665,17 @@ static bool evalShuffleGeneric( | |||||
| if (SrcIdx < 0) { | ||||||
| // Zero out this element | ||||||
| QualType ElemTy = VT->getElementType(); | ||||||
| ResultElements.push_back( | ||||||
| APValue(APFloat::getZero(Info.Ctx.getFloatTypeSemantics(ElemTy)))); | ||||||
| if (ElemTy->isRealFloatingType()) { | ||||||
| ResultElements.push_back( | ||||||
| APValue(APFloat::getZero(Info.Ctx.getFloatTypeSemantics(ElemTy)))); | ||||||
| } else if (ElemTy->isIntegerType()) { | ||||||
| APValue Zero(Info.Ctx.MakeIntValue(0, ElemTy)); | ||||||
| ResultElements.push_back(APValue(Zero)); | ||||||
| } else { | ||||||
| // Other types of fallback logic | ||||||
| ResultElements.push_back(APValue()); | ||||||
| } | ||||||
|
|
||||||
| } else { | ||||||
| const APValue &Src = (SrcVecIdx == 0) ? A : B; | ||||||
| ResultElements.push_back(Src.getVectorElt(SrcIdx)); | ||||||
|
|
@@ -13097,6 +13106,33 @@ bool VectorExprEvaluator::VisitCallExpr(const CallExpr *E) { | |||||
|
|
||||||
| return Success(APValue(ResultElements.data(), ResultElements.size()), E); | ||||||
| } | ||||||
|
|
||||||
| case X86::BI__builtin_ia32_palignr128: | ||||||
| case X86::BI__builtin_ia32_palignr256: | ||||||
| case X86::BI__builtin_ia32_palignr512: { | ||||||
| APValue R; | ||||||
| if (!evalShuffleGeneric(Info, E, R, [](unsigned DstIdx, unsigned Shift) { | ||||||
| // Default to -1 → zero-fill this destination element | ||||||
| unsigned VecIdx = 1; | ||||||
| int ElemIdx = -1; | ||||||
|
|
||||||
| int Lane = DstIdx / 16; | ||||||
| int Offset = DstIdx % 16; | ||||||
|
|
||||||
| // Elements come from VecB first, then VecA after the shift boundary | ||||||
| unsigned ShiftedIdx = Offset + Shift; | ||||||
|
||||||
| unsigned ShiftedIdx = Offset + Shift; | |
| unsigned ShiftedIdx = Offset + (Shift & 0xFF); |
Outdated
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.
| ElemIdx = ShiftedIdx + Lane * 16; | |
| ElemIdx = ShiftedIdx + (Lane * 16); |
Outdated
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.
| ElemIdx = ShiftedIdx - 16 + Lane * 16; | |
| ElemIdx = (ShiftedIdx - 16) + (Lane * 16); |
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.