[PATCH] D88316: [InstCombine] recognizeBSwapOrBitReverseIdiom - recognise zext(bswap(trunc(x))) patterns (PR39793)
Roman Lebedev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 11:44:14 PDT 2020
lebedev.ri accepted this revision.
lebedev.ri added a comment.
This revision is now accepted and ready to land.
Looks good to me. @spatel ?
================
Comment at: llvm/lib/Transforms/Utils/Local.cpp:3026-3037
+ // If the upper bits are zero, then attempt to perform as a truncated op.
+ if (BitProvenance[BitProvenance.size() - 1] < 0) {
+ unsigned NumBits = BitProvenance.size();
+ unsigned NumUpperZeroBits = 1;
+ while (NumBits > NumUpperZeroBits &&
+ BitProvenance[NumBits - 1 - NumUpperZeroBits] < 0)
+ ++NumUpperZeroBits;
----------------
Suggestion:
```
while(!BitProvenance.empty() && BitProvenance.back() < 0)
BitProvenance = BitProvenance.drop_back();
if(BitProvenance.empty())
???
DemandedTy = IntegerType::get(I->getContext(), BitProvenance.size());
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88316/new/
https://reviews.llvm.org/D88316
More information about the llvm-commits
mailing list