[llvm] 869d231 - [GlobalOpt] Remove unnecessary bitcasts (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 04:03:36 PDT 2023
Author: Nikita Popov
Date: 2023-08-23T13:03:28+02:00
New Revision: 869d231bc4ee353ddb1adfe35ba181ecc1af7e69
URL: https://github.com/llvm/llvm-project/commit/869d231bc4ee353ddb1adfe35ba181ecc1af7e69
DIFF: https://github.com/llvm/llvm-project/commit/869d231bc4ee353ddb1adfe35ba181ecc1af7e69.diff
LOG: [GlobalOpt] Remove unnecessary bitcasts (NFC)
Added:
Modified:
llvm/lib/Transforms/IPO/GlobalOpt.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 245ea77bd805ee..3be19f46ee8478 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -932,9 +932,6 @@ OptimizeGlobalAddressOfAllocation(GlobalVariable *GV, CallInst *CI,
// Update users of the allocation to use the new global instead.
CI->replaceAllUsesWith(NewGV);
- SmallSetVector<Constant *, 1> RepValues;
- RepValues.insert(NewGV);
-
// If there is a comparison against null, we will insert a global bool to
// keep track of whether the global was initialized yet or not.
GlobalVariable *InitBool =
@@ -965,9 +962,7 @@ OptimizeGlobalAddressOfAllocation(GlobalVariable *GV, CallInst *CI,
Use &LoadUse = *LI->use_begin();
ICmpInst *ICI = dyn_cast<ICmpInst>(LoadUse.getUser());
if (!ICI) {
- auto *CE = ConstantExpr::getBitCast(NewGV, LI->getType());
- RepValues.insert(CE);
- LoadUse.set(CE);
+ LoadUse.set(NewGV);
continue;
}
@@ -1013,8 +1008,7 @@ OptimizeGlobalAddressOfAllocation(GlobalVariable *GV, CallInst *CI,
// To further other optimizations, loop over all users of NewGV and try to
// constant prop them. This will promote GEP instructions with constant
// indices into GEP constant-exprs, which will allow global-opt to hack on it.
- for (auto *CE : RepValues)
- ConstantPropUsersOf(CE, DL, TLI);
+ ConstantPropUsersOf(NewGV, DL, TLI);
return NewGV;
}
@@ -1569,7 +1563,7 @@ processInternalGlobal(GlobalVariable *GV, const GlobalStatus &GS,
GV->getAddressSpace());
NGV->takeName(GV);
NGV->copyAttributesFrom(GV);
- GV->replaceAllUsesWith(ConstantExpr::getBitCast(NGV, GV->getType()));
+ GV->replaceAllUsesWith(NGV);
GV->eraseFromParent();
GV = NGV;
}
@@ -2278,7 +2272,7 @@ OptimizeGlobalAliases(Module &M,
if (!hasUsesToReplace(J, Used, RenameTarget))
continue;
- J.replaceAllUsesWith(ConstantExpr::getBitCast(Aliasee, J.getType()));
+ J.replaceAllUsesWith(Aliasee);
++NumAliasesResolved;
Changed = true;
More information about the llvm-commits
mailing list