rldicl/rldicr can be eliminated if it's used to clear the high-order or low-order n bits and all bits cleared will be ANDed with 0 by andi/andis.
This patch optimizes such pattern.
Details
- Reviewers
shchenz lkail qiucf tingwang - Group Reviewers
Restricted Project - Commits
- rGd7195c57d823: Reland https://reviews.llvm.org/D159073.
rG2de74e1bd4d5: [PowerPC][Peephole] Combine rldicl/rldicr and andi/andis after isel.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | ||
---|---|---|
1287 | So we should guard this optimization before RA? | |
1313 | A follow up: is it possible to get result 0 for the ANDI if we know RLDICR clears more than andi masks, or for the ANDIS, if we know RLDICL leading 0 count is not smaller than 48? There should be other combinations... And if we are going to handle this case, maybe SHSrc does not need to be 0. |
Addressed comments -- handled more cases.
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | ||
---|---|---|
1287 | Yes, I do guard it by if (!TrueReg.isVirtual()) break; | |
1313 | Good point! In such scenarios we can eliminate ANDI_rec/ANDIS_rec instead of RLDICL/RLDICR and replace RLDICL/RLDICR with their record form RLDICL_rec/RLDICR_rec. |
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | ||
---|---|---|
1299 | If we know that all bits to AND are already zero, why not we can just delete the RLDICL/RLDICR, and set the operand 2 of ANDI/ANDIS to 0 to indicate that ANDI/ANDIS products 0 result here? To me that would be more simple and later pass may have the opportunity to do more optimizations based on the 0? |
LGTM with one nit.
Thanks for improving this.
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | ||
---|---|---|
1299 | nit: PatternResultZero & PatternRemoveRotate for Pattern1 and Pattern2? |
llvm/lib/Target/PowerPC/PPCMIPeephole.cpp | ||
---|---|---|
1247 | JTBC. The patch was committed with addRegToUpdate() after rebasing on https://reviews.llvm.org/D133103. |
JTBC. The patch was committed with addRegToUpdate() after rebasing on https://reviews.llvm.org/D133103.