summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ValueNumbering.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-11-20 01:22:35 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-11-20 01:22:35 +0000
commitd9436b6837e27d93a2ac82ef7dfc2c742be0fe69 (patch)
tree085e61911bc5ecbd81c027bd5a5f163810088c47 /llvm/lib/Analysis/ValueNumbering.cpp
parent9f4448a26ef8f7e8be847bf7bce4b6e525743af1 (diff)
downloadbcm5719-llvm-d9436b6837e27d93a2ac82ef7dfc2c742be0fe69.tar.gz
bcm5719-llvm-d9436b6837e27d93a2ac82ef7dfc2c742be0fe69.zip
For PR950:
First in a series of patches to convert SetCondInst into ICmpInst and FCmpInst using only two opcodes and having the instructions contain their predicate value. Nothing uses these classes yet. More patches to follow. llvm-svn: 31867
Diffstat (limited to 'llvm/lib/Analysis/ValueNumbering.cpp')
-rw-r--r--llvm/lib/Analysis/ValueNumbering.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ValueNumbering.cpp b/llvm/lib/Analysis/ValueNumbering.cpp
index 0224a0132fd..03b9f6b3eae 100644
--- a/llvm/lib/Analysis/ValueNumbering.cpp
+++ b/llvm/lib/Analysis/ValueNumbering.cpp
@@ -75,6 +75,7 @@ namespace {
void visitCastInst(CastInst &I);
void visitGetElementPtrInst(GetElementPtrInst &I);
+ void visitCmpInst(CmpInst &I);
void handleBinaryInst(Instruction &I);
void visitBinaryOperator(Instruction &I) { handleBinaryInst(I); }
@@ -124,6 +125,28 @@ void BVNImpl::visitCastInst(CastInst &CI) {
}
}
+void BVNImpl::visitCmpInst(CmpInst &CI1) {
+ Value *LHS = CI1.getOperand(0);
+ for (Value::use_iterator UI = LHS->use_begin(), UE = LHS->use_end();
+ UI != UE; ++UI)
+ if (CmpInst *CI2 = dyn_cast<CmpInst>(*UI))
+ // Check to see if this compare instruction is not CI, but same opcode,
+ // same predicate, and in the same function.
+ if (CI2 != &CI1 && CI2->getOpcode() == CI1.getOpcode() &&
+ CI2->getPredicate() == CI1.getPredicate() &&
+ CI2->getParent()->getParent() == CI1.getParent()->getParent())
+ // If the operands are the same
+ if ((CI2->getOperand(0) == CI1.getOperand(0) &&
+ CI2->getOperand(1) == CI1.getOperand(1)) ||
+ // Or the compare is commutative and the operands are reversed
+ (CI1.isCommutative() &&
+ CI2->getOperand(0) == CI1.getOperand(1) &&
+ CI2->getOperand(1) == CI1.getOperand(0)))
+ // Then the instructiosn are identical, add to list.
+ RetVals.push_back(CI2);
+}
+
+
// isIdenticalBinaryInst - Return true if the two binary instructions are
// identical.
OpenPOWER on IntegriCloud