aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/Local.cpp
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2022-01-05 11:53:59 -0500
committerSanjay Patel <spatel@rotateright.com>2022-01-05 13:04:11 -0500
commite2165e096869ef5bd5150c150a1cbfc25f693a0f (patch)
treebdbe343e028b23f7961b16abf995c2ee3cbf6aae /llvm/lib/Transforms/Utils/Local.cpp
parent06cc2f2f122ab2ce6c2ffb5cd6f87f0334919ca3 (diff)
downloadllvm-e2165e096869ef5bd5150c150a1cbfc25f693a0f.zip
llvm-e2165e096869ef5bd5150c150a1cbfc25f693a0f.tar.gz
llvm-e2165e096869ef5bd5150c150a1cbfc25f693a0f.tar.bz2
[InstCombine] remove trunc user restriction for match of bswap
This does not appear to cause any problems, and it fixes #50910 Extra tests with a trunc user were added with: 3a239379 ...but they don't match either way, so there's an opportunity to improve the matching further.
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/Local.cpp6
1 files changed, 1 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index ecad79b..efc5396 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3147,11 +3147,6 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
if (!ITy->isIntOrIntVectorTy() || ITy->getScalarSizeInBits() > 128)
return false; // Can't do integer/elements > 128 bits.
- Type *DemandedTy = ITy;
- if (I->hasOneUse())
- if (auto *Trunc = dyn_cast<TruncInst>(I->user_back()))
- DemandedTy = Trunc->getType();
-
// Try to find all the pieces corresponding to the bswap.
bool FoundRoot = false;
std::map<Value *, Optional<BitPart>> BPS;
@@ -3165,6 +3160,7 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
"Illegal bit provenance index");
// If the upper bits are zero, then attempt to perform as a truncated op.
+ Type *DemandedTy = ITy;
if (BitProvenance.back() == BitPart::Unset) {
while (!BitProvenance.empty() && BitProvenance.back() == BitPart::Unset)
BitProvenance = BitProvenance.drop_back();