[llvm-commits] [llvm] r37860 - /llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp
Owen Anderson
resistor at mac.com
Tue Jul 3 15:50:57 PDT 2007
Author: resistor
Date: Tue Jul 3 17:50:56 2007
New Revision: 37860
URL: http://llvm.org/viewvc/llvm-project?rev=37860&view=rev
Log:
Add functionality to value number GEP instructions. This also provides the infrastructure that will
be used for function calls. NOTE: This does not yet do any transformation of GEPs or function calls.
Modified:
llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp?rev=37860&r1=37859&r2=37860&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/GVNPRE.cpp Tue Jul 3 17:50:56 2007
@@ -62,13 +62,14 @@
FCMPULT, FCMPULE, FCMPUNE, EXTRACT, INSERT,
SHUFFLE, SELECT, TRUNC, ZEXT, SEXT, FPTOUI,
FPTOSI, UITOFP, SITOFP, FPTRUNC, FPEXT,
- PTRTOINT, INTTOPTR, BITCAST};
+ PTRTOINT, INTTOPTR, BITCAST, GEP};
ExpressionOpcode opcode;
const Type* type;
uint32_t firstVN;
uint32_t secondVN;
uint32_t thirdVN;
+ std::vector<uint32_t> varargs;
bool operator< (const Expression& other) const {
if (opcode < other.opcode)
@@ -91,8 +92,20 @@
return true;
else if (thirdVN > other.thirdVN)
return false;
- else
+ else {
+ if (varargs.size() < other.varargs.size())
+ return true;
+ else if (varargs.size() > other.varargs.size())
+ return false;
+
+ for (size_t i = 0; i < varargs.size(); ++i)
+ if (varargs[i] < other.varargs[i])
+ return true;
+ else if (varargs[i] > other.varargs[i])
+ return false;
+
return false;
+ }
}
};
@@ -112,6 +125,7 @@
Expression create_expression(InsertElementInst* V);
Expression create_expression(SelectInst* V);
Expression create_expression(CastInst* C);
+ Expression create_expression(GetElementPtrInst* G);
public:
ValueTable() { nextValueNumber = 1; }
uint32_t lookup_or_add(Value* V);
@@ -354,6 +368,22 @@
return e;
}
+ValueTable::Expression ValueTable::create_expression(GetElementPtrInst* G) {
+ Expression e;
+
+ e.firstVN = lookup_or_add(G->getPointerOperand());
+ e.secondVN = 0;
+ e.thirdVN = 0;
+ e.type = G->getType();
+ e.opcode = Expression::SELECT;
+
+ for (GetElementPtrInst::op_iterator I = G->idx_begin(), E = G->idx_end();
+ I != E; ++I)
+ e.varargs.push_back(lookup_or_add(*I));
+
+ return e;
+}
+
//===----------------------------------------------------------------------===//
// ValueTable External Functions
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list