Instruction::isAssociative() returns true for fmul/fadd if they are tagged "unsafe...
[oota-llvm.git] / lib / VMCore / Instruction.cpp
index 4208144cb5b5c6df0b174218cb505bdc02eb3058..d93c1d7a22c04b26ca75d53265a89b8597429558 100644 (file)
@@ -468,6 +468,20 @@ bool Instruction::isAssociative(unsigned Opcode) {
          Opcode == Add || Opcode == Mul;
 }
 
+bool Instruction::isAssociative() const {
+  unsigned Opcode = getOpcode();
+  if (isAssociative(Opcode))
+    return true;
+
+  switch (Opcode) {
+  case FMul:
+  case FAdd:
+    return cast<FPMathOperator>(this)->hasUnsafeAlgebra();
+  default:
+    return false;
+  }
+}
+
 /// isCommutative - Return true if the instruction is commutative:
 ///
 ///   Commutative operators satisfy: (x op y) === (y op x)