Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
llvm-epi-0.8
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Roger Ferrer
llvm-epi-0.8
Commits
81eb193f
Commit
81eb193f
authored
13 years ago
by
Bruno Cardoso Lopes
Browse files
Options
Downloads
Patches
Plain Diff
Match VPERMIL masks more strictly and update the target specific mask
generation to always catch the weird cases. llvm-svn: 136453
parent
795f5585
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/lib/Target/X86/X86ISelLowering.cpp
+17
-7
17 additions, 7 deletions
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/test/CodeGen/X86/avx-vpermil.ll
+10
-0
10 additions, 0 deletions
llvm/test/CodeGen/X86/avx-vpermil.ll
with
27 additions
and
7 deletions
llvm/lib/Target/X86/X86ISelLowering.cpp
+
17
−
7
View file @
81eb193f
...
...
@@ -3465,11 +3465,14 @@ static bool isVPERMILPSMask(const SmallVectorImpl<int> &Mask, EVT VT,
return false;
// The mask on the high lane should be the same as the low. Actually,
// they can differ if any of the corresponding index in a lane is undef.
// they can differ if any of the corresponding index in a lane is undef
// and the other stays in range.
int LaneSize = NumElts/NumLanes;
for (int i = 0; i < LaneSize; ++i) {
int HighElt = i+LaneSize;
if (Mask[i] < 0 || Mask[HighElt] < 0)
if (Mask[i] < 0 && (isUndefOrInRange(Mask[HighElt], LaneSize, NumElts)))
continue;
if (Mask[HighElt] < 0 && (isUndefOrInRange(Mask[i], 0, LaneSize)))
continue;
if (Mask[HighElt]-Mask[i] != LaneSize)
return false;
...
...
@@ -3486,13 +3489,20 @@ static unsigned getShuffleVPERMILPSImmediate(SDNode *N) {
int NumElts = VT.getVectorNumElements();
int NumLanes = VT.getSizeInBits()/128;
int LaneSize = NumElts/NumLanes;
// Although the mask is equal for both lanes do it twice to get the cases
// where a mask will match because the same mask element is undef on the
// first half but valid on the second. This would get pathological cases
// such as: shuffle <u, 0, 1, 2, 4, 4, 5, 6>, which is completely valid.
unsigned Mask = 0;
for (int i = 0; i < NumElts/NumLanes /* lane size */; ++i) {
int MaskElt = SVOp->getMaskElt(i);
if (MaskElt < 0)
continue;
Mask |= MaskElt << (i*2);
for (int l = 0; l < NumLanes; ++l) {
for (int i = 0; i < LaneSize; ++i) {
int MaskElt = SVOp->getMaskElt(i+(l*LaneSize));
if (MaskElt < 0)
continue;
Mask |= MaskElt << (i*2);
}
}
return Mask;
...
...
This diff is collapsed.
Click to expand it.
llvm/test/CodeGen/X86/avx-vpermil.ll
+
10
−
0
View file @
81eb193f
...
...
@@ -27,3 +27,13 @@ entry:
%shuffle
=
shufflevector
<
4
x
i64
>
%a
,
<
4
x
i64
>
undef
,
<
4
x
i32
>
<
i32
1
,
i32
0
,
i32
3
,
i32
3
>
ret
<
4
x
i64
>
%shuffle
}
; vpermil should match masks like this: <u,3,1,2,4,u,5,6>. Check that the
; target specific mask was correctly generated.
; CHECK: vpermilps $-100
define
<
8
x
float
>
@funcA
(<
8
x
float
>
%a
)
nounwind
uwtable
readnone
ssp
{
entry:
%shuffle
=
shufflevector
<
8
x
float
>
%a
,
<
8
x
float
>
undef
,
<
8
x
i32
>
<
i32
8
,
i32
3
,
i32
1
,
i32
2
,
i32
4
,
i32
8
,
i32
5
,
i32
6
>
ret
<
8
x
float
>
%shuffle
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment