[PATCH] D124897: Extend switch condition in optimizeSwitchPhiConst when free
Sanjay Patel via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 17 13:07:19 PDT 2022
spatel accepted this revision.
spatel added a comment.
This revision is now accepted and ready to land.
The previous patches seem to be stable now, so LGTM with a couple of minor improvements.
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7056
+ // and replace `(i64)42` with `zext i32 %x to i64`.
+ bool tryZExt =
+ PHIType->isIntegerTy() &&
----------------
formatting: TryZext or TryZExt
================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:7066-7069
+ if (PHIValue != CaseValue &&
+ (!tryZExt || !isa<ConstantInt>(PHIValue) ||
+ cast<ConstantInt>(PHIValue)->getValue() !=
+ CaseValue->getValue().zext(PHIType->getIntegerBitWidth())))
----------------
Prefer dyn_cast to isa + cast, so something like this:
auto *PHIValue = dyn_cast<ConstantInt>(PHI.getIncomingValue(I));
if (PHIValue != CaseValue)
if (!tryZExt || !PHIValue ||
PHIValue->getValue() !=
CaseValue->getValue().zext(PHIType->getIntegerBitWidth()))
continue;
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124897/new/
https://reviews.llvm.org/D124897
More information about the llvm-commits
mailing list