It seems the ISA manual's pseudo-code description for the
BYTEPICK.[WD] instructions is inaccurate; the behavior described here
should be correct though. The instructions' names are misleading too
(they pick full GRLen-wide words instead of bytes; they just index by
bytes) but let's stick to the official names for now.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
@xry111: BTW your GCC implementation of this pattern looks for *arithmetic* right shifts; do you mean logical instead? Because obviously the higher bits would be full of ones after shifting if rj happen to have its MSB set. The sign extension shall happen *after* the pick.
Comment Actions
Self note: the pattern may need more love, because the signext i32 cases appear wrong on LA64.
Comment Actions
My bad, I'm not familiar with GCC RTL patterns so I've mistakenly thought "lshiftrt could be some 'left' shift, so ashift must be an arithmetic right shift". Actually your pattern is correct as you have perfect test coverage. Please ignore my comment...
Comment Actions
LGTM. Thanks!
Yes, I think the ISA's pseudo-code description is incorrect. Maybe it shoud be:
bytepick.w: tmp = {GR[rk][31:0], GR[rj][31:0]} GR[rd] = SignExtend(tmp[8×(8-sa2)-1:8×(4-sa2)], GRLEN) or GR[rd] = SignExtend(tmp[8×(4-sa2)+31:8×(4-sa2)], GRLEN)