[llvm-commits] CVS: llvm/lib/Transforms/IPO/GlobalOpt.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sun Nov 14 12:50:43 PST 2004
Changes in directory llvm/lib/Transforms/IPO:
GlobalOpt.cpp updated: 1.26 -> 1.27
---
Log message:
If a global is just loaded and restored, realize that it is not changing
value. This allows us to turn more globals into constants and eliminate them.
This patch implements GlobalOpt/load-store-global.llx.
Note that this patch speeds up 255.vortex from:
Output/255.vortex.out-cbe.time:program 7.640000
Output/255.vortex.out-llc.time:program 9.810000
to:
Output/255.vortex.out-cbe.time:program 7.250000
Output/255.vortex.out-llc.time:program 9.490000
Which isn't bad at all!
---
Diffs of the changes: (+9 -3)
Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp
diff -u llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.26 llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.27
--- llvm/lib/Transforms/IPO/GlobalOpt.cpp:1.26 Fri Oct 22 01:43:28 2004
+++ llvm/lib/Transforms/IPO/GlobalOpt.cpp Sun Nov 14 14:50:30 2004
@@ -155,14 +155,20 @@
// stores.
if (GS.StoredType != GlobalStatus::isStored)
if (GlobalVariable *GV = dyn_cast<GlobalVariable>(SI->getOperand(1))){
- if (SI->getOperand(0) == GV->getInitializer()) {
+ Value *StoredVal = SI->getOperand(0);
+ if (StoredVal == GV->getInitializer()) {
+ if (GS.StoredType < GlobalStatus::isInitializerStored)
+ GS.StoredType = GlobalStatus::isInitializerStored;
+ } else if (isa<LoadInst>(StoredVal) &&
+ cast<LoadInst>(StoredVal)->getOperand(0) == GV) {
+ // G = G
if (GS.StoredType < GlobalStatus::isInitializerStored)
GS.StoredType = GlobalStatus::isInitializerStored;
} else if (GS.StoredType < GlobalStatus::isStoredOnce) {
GS.StoredType = GlobalStatus::isStoredOnce;
- GS.StoredOnceValue = SI->getOperand(0);
+ GS.StoredOnceValue = StoredVal;
} else if (GS.StoredType == GlobalStatus::isStoredOnce &&
- GS.StoredOnceValue == SI->getOperand(0)) {
+ GS.StoredOnceValue == StoredVal) {
// noop.
} else {
GS.StoredType = GlobalStatus::isStored;
More information about the llvm-commits
mailing list