-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[RISCV] Match prefetch address with offset #66072
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
[RISCV] Match prefetch address with offset #66072
Conversation
@llvm/pr-subscribers-backend-risc-v ChangesA new ComplexPattern
|
ec47ce5
to
6036775
Compare
Ping. |
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 I would rather see a SelectAddr function for prefetch that handles just the cases that are really tested. You can move parts of SelectAddrRegImm into functions to reuse them if needed, but don't try to make SelectAddrRegImm handle both cases.
8c5bfb1
to
4e8961c
Compare
✅ With the latest revision this PR passed the C/C++ code formatter. |
Align Alignment = commonAlignment( | ||
GA->getGlobal()->getPointerAlignment(DL), GA->getOffset()); | ||
int64_t CombinedOffset = CVal + GA->getOffset(); | ||
if (((CombinedOffset & 0b11111) == 0) && |
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.
CombinedOffset being aligned isn't enough. You would also need the global itself to be aligned to at least 32 bytes. If the global isn't aligned, the base address of global + CombinedOffset might not be 32 byte aligned.
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 decide to not handle global address since we don't have reloc type for prefetch (correct me if I am wrong):
lui a0, %hi(g)
ntl.all
prefetch.r %lo(g+32)(a0) // This will be messed-up.
ret
4e8961c
to
92d7f96
Compare
Ping. |
return true; | ||
} | ||
|
||
if (auto *FIN = dyn_cast<FrameIndexSDNode>(Base)) |
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 don't think we can fold a FrameIndex. When the FrameIndex is eliminated won't it modify the constant and potentially create a constant that isn't aligned?
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 I have handled the case in RISCVRegisterInfo::eliminateFrameIndex
?
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.
Sorry I missed that change.
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.
LGTM
A new ComplexPattern `AddrRegImmLsb00000` is added, which is like `AddrRegImm` except that if the least significant 5 bits isn't all zeros, we will fail back to offset 0.
7e8e977
to
77f1507
Compare
A new ComplexPattern
AddrRegImmLsb00000
is added, which is likeAddrRegImm
except that if the least significant 5 bits isn't allzeros, we will fail back to offset 0.
This PR is stacked on #67644.