[llvm] c722b32 - [InstCombine] recognizeBSwapOrBitReverseIdiom - merge the regular/trunc+zext paths. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 07:04:40 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-30T14:54:04+01:00
New Revision: c722b3259690d3aad20f31d0ffe6c12b1416bccc
URL: https://github.com/llvm/llvm-project/commit/c722b3259690d3aad20f31d0ffe6c12b1416bccc
DIFF: https://github.com/llvm/llvm-project/commit/c722b3259690d3aad20f31d0ffe6c12b1416bccc.diff
LOG: [InstCombine] recognizeBSwapOrBitReverseIdiom - merge the regular/trunc+zext paths. NFCI.
There doesn't seem to be any good reason for having a separate path for when we bswap/bitreverse at a smaller size than the destination size - so merge these to make the instruction generation a lot clearer.
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index f8e4d34cbf4e..0dacb266a063 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3056,25 +3056,26 @@ bool llvm::recognizeBSwapOrBitReverseIdiom(
else
return false;
- if (ITy != DemandedTy) {
- Function *F = Intrinsic::getDeclaration(I->getModule(), Intrin, DemandedTy);
- Value *Provider = Res->Provider;
- // We may need to truncate the provider.
- if (DemandedTy != Provider->getType()) {
- auto *Trunc = CastInst::Create(Instruction::Trunc, Provider, DemandedTy,
- "trunc", I);
- InsertedInsts.push_back(Trunc);
- Provider = Trunc;
- }
- auto *CI = CallInst::Create(F, Provider, "rev", I);
- InsertedInsts.push_back(CI);
+ Function *F = Intrinsic::getDeclaration(I->getModule(), Intrin, DemandedTy);
+ Value *Provider = Res->Provider;
+
+ // We may need to truncate the provider.
+ if (DemandedTy != Provider->getType()) {
+ auto *Trunc =
+ CastInst::Create(Instruction::Trunc, Provider, DemandedTy, "trunc", I);
+ InsertedInsts.push_back(Trunc);
+ Provider = Trunc;
+ }
+
+ auto *CI = CallInst::Create(F, Provider, "rev", I);
+ InsertedInsts.push_back(CI);
+
+ // We may need to zeroextend back to the result type.
+ if (ITy != CI->getType()) {
auto *ExtInst = CastInst::Create(Instruction::ZExt, CI, ITy, "zext", I);
InsertedInsts.push_back(ExtInst);
- return true;
}
- Function *F = Intrinsic::getDeclaration(I->getModule(), Intrin, ITy);
- InsertedInsts.push_back(CallInst::Create(F, Res->Provider, "rev", I));
return true;
}
More information about the llvm-commits
mailing list