Added LLVM project notice to the top of every C++ source file.
[oota-llvm.git] / lib / Analysis / ValueNumbering.cpp
index 519d9dbf97f08656b4a1d34b9be0919a53949665..075c1c2b3f8da9d5ffd6b806321234356ee7f7b3 100644 (file)
@@ -1,4 +1,11 @@
 //===- ValueNumbering.cpp - Value #'ing Implementation ----------*- C++ -*-===//
+// 
+//                     The LLVM Compiler Infrastructure
+//
+// This file was developed by the LLVM research group and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+// 
+//===----------------------------------------------------------------------===//
 //
 // This file implements the non-abstract Value Numbering methods as well as a
 // default implementation for the analysis group.
@@ -100,7 +107,7 @@ void BVNImpl::visitCastInst(CastInst &CI) {
       // Check to see if this new cast is not I, but has the same operand...
       if (Other != &I && Other->getOpcode() == I.getOpcode() &&
           Other->getOperand(0) == Op &&     // Is the operand the same?
-          // Is it embeded in the same function?  (This could be false if LHS
+          // Is it embedded in the same function?  (This could be false if LHS
           // is a constant or global!)
           Other->getParent()->getParent() == F &&
 
@@ -118,7 +125,7 @@ void BVNImpl::visitCastInst(CastInst &CI) {
 //
 static inline bool isIdenticalBinaryInst(const Instruction &I1,
                                          const Instruction *I2) {
-  // Is it embeded in the same function?  (This could be false if LHS
+  // Is it embedded in the same function?  (This could be false if LHS
   // is a constant or global!)
   if (I1.getOpcode() != I2->getOpcode() ||
       I1.getParent()->getParent() != I2->getParent()->getParent())
@@ -129,16 +136,12 @@ static inline bool isIdenticalBinaryInst(const Instruction &I1,
       I1.getOperand(1) == I2->getOperand(1))
     return true;
   
-  // If the instruction is commutative and associative, the instruction can
-  // match if the operands are swapped!
+  // If the instruction is commutative, the instruction can match if the
+  // operands are swapped!
   //
   if ((I1.getOperand(0) == I2->getOperand(1) &&
        I1.getOperand(1) == I2->getOperand(0)) &&
-      (I1.getOpcode() == Instruction::Add || 
-       I1.getOpcode() == Instruction::Mul ||
-       I1.getOpcode() == Instruction::And || 
-       I1.getOpcode() == Instruction::Or  ||
-       I1.getOpcode() == Instruction::Xor))
+      I1.isCommutative())
     return true;
 
   return false;