-
Notifications
You must be signed in to change notification settings - Fork 14
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
[AIEX] Combine G_SHUFFLE_VECTOR to COPY #346
Changes from all commits
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 |
---|---|---|
|
@@ -34,6 +34,34 @@ struct AIELoadStoreCombineMatchData { | |
bool RemoveInstr; | ||
}; | ||
|
||
/// The mask is represented by a sawtooth function F with Period, Height and | ||
/// Amplitude, i.e., F(idx + Period) = F(idx) = Height + idx * Amplitude, where | ||
/// idx >= 0. | ||
/// Example: mask = (4, 6, 8, 4, 6, 8) <=> Height=4, Amplitude=2, Period=3 | ||
class MaskMatch { | ||
public: | ||
MaskMatch(unsigned MaskHeight, unsigned MaskPeriod = 0, int MaskAmplitude = 1) | ||
: Period{MaskPeriod}, Height{MaskHeight}, Amplitude{MaskAmplitude} {} | ||
|
||
bool isValidMask(ArrayRef<int> Mask) const; | ||
unsigned getHeight() const { return Height; } | ||
|
||
static bool isMaskWithAllUndefs(ArrayRef<int> Mask); | ||
static std::optional<unsigned> getHeight(ArrayRef<int> Mask, unsigned Period); | ||
static std::optional<int> getUniqueIndex(ArrayRef<int> Mask); | ||
|
||
protected: | ||
unsigned getMaskValue(unsigned Idx) const { | ||
unsigned BaseIdx = Period == 0 ? Idx : Idx % Period; | ||
return Height + BaseIdx * Amplitude; | ||
} | ||
|
||
unsigned Period = 0; | ||
unsigned Height = 0; | ||
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. I had imagined these as std::optional, indicating that they were free parameters. Then, the match function, isValidMask, would use this freedom to make it match the given mask. Matching on a mask without dont-care values, it would fix Height on the first element, the Amplitude on the second, and period when the sawtooth ended. It would return false the first time it couldn't adjust a free parameter. If you would know the period that you were looking for, you would initialize it with concrete values using a constructor, or a setter function. 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. But don't pursue this idea at this point. It is already good to have it factored this far. |
||
/// Negative amplitude can be used for reverse mask patterns. | ||
int Amplitude = 1; | ||
}; | ||
|
||
/// Look for any PtrAdd instruction that use the same base as \a MI that can be | ||
/// combined with it and stores it in \a MatchData | ||
/// \return true if an instruction is found | ||
|
@@ -211,6 +239,9 @@ bool matchShuffleToExtractSubvec(MachineInstr &MI, MachineRegisterInfo &MRI, | |
const AIEBaseInstrInfo &TII, | ||
BuildFnTy &MatchInfo); | ||
|
||
bool matchShuffleToCopy(MachineInstr &MI, MachineRegisterInfo &MRI, | ||
BuildFnTy &MatchInfo); | ||
|
||
} // namespace llvm | ||
|
||
#endif |
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.
Can we use something like this:
?
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.
But I guess that this could trigger some clang frontend bug....
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.
With this I am getting the following error: " error: reference to local binding 'DstReg' declared in enclosing function 'llvm::matchShuffleToCopy'
MatchInfo = [=](MachineIRBuilder &B) { B.buildCopy(DstReg, Src1Reg); };"
and the same error for
Src1Reg
.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.
I think that this is a clang bug.
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.
That means that you can explain every line from the C++ standard related to structural bindings? Respect.