Skip to content

Commit

Permalink
[CVP] Preserve exact name when converting sext->zext and ashr->lshr.
Browse files Browse the repository at this point in the history
Previously we took the old name and always appended a numberic suffix.
Since we're doing a 1:1 replacement, it's clearer to keep the original
name exactly.

Reviewed By: fhahn

Differential Revision: https://reviews.llvm.org/D125281
  • Loading branch information
topperc committed May 10, 2022
1 parent 7b362dd commit 4b36d9b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
Expand Up @@ -961,7 +961,8 @@ static bool processAShr(BinaryOperator *SDI, LazyValueInfo *LVI) {

++NumAShrsConverted;
auto *BO = BinaryOperator::CreateLShr(SDI->getOperand(0), SDI->getOperand(1),
SDI->getName(), SDI);
"", SDI);
BO->takeName(SDI);
BO->setDebugLoc(SDI->getDebugLoc());
BO->setIsExact(SDI->isExact());
SDI->replaceAllUsesWith(BO);
Expand All @@ -980,8 +981,8 @@ static bool processSExt(SExtInst *SDI, LazyValueInfo *LVI) {
return false;

++NumSExt;
auto *ZExt =
CastInst::CreateZExtOrBitCast(Base, SDI->getType(), SDI->getName(), SDI);
auto *ZExt = CastInst::CreateZExtOrBitCast(Base, SDI->getType(), "", SDI);
ZExt->takeName(SDI);
ZExt->setDebugLoc(SDI->getDebugLoc());
SDI->replaceAllUsesWith(ZExt);
SDI->eraseFromParent();
Expand Down

0 comments on commit 4b36d9b

Please sign in to comment.