Make error messages more useful than jsut an abort
[oota-llvm.git] / lib / Analysis / ValueNumbering.cpp
index 32e4439eaaba591352d68eed59b1847e6053aad2..53d70e84b5732704b0b70e4a541724e844ed8683 100644 (file)
@@ -38,18 +38,7 @@ namespace {
   /// lexically identical expressions.  This does not require any ahead of time
   /// analysis, so it is a very fast default implementation.
   ///
-  struct BasicVN : public FunctionPass, public ValueNumbering {
-  
-    /// Pass Implementation stuff.  This isn't much of a pass.
-    ///
-    bool runOnFunction(Function &) { return false; }
-    
-    /// getAnalysisUsage - Does not modify anything.
-    ///
-    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.setPreservesAll();
-    }
-  
+  struct BasicVN : public ImmutablePass, public ValueNumbering {
     /// getEqualNumberNodes - Return nodes with the same value number as the
     /// specified Value.  This fills in the argument vector with any equal
     /// values.
@@ -140,16 +129,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;