aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorShuxin Yang <shuxin.llvm@gmail.com>2012-11-29 01:47:31 +0000
committerShuxin Yang <shuxin.llvm@gmail.com>2012-11-29 01:47:31 +0000
commit9b7f6f2de89a321f7eae5e942c8668cb50acfd1d (patch)
tree3f34a5f5d5e79b5f79237baf71ae60f7037d538c /lib/VMCore
parent89bea17af235ea3a69485e73e54e71053c1bd936 (diff)
downloadexternal_llvm-9b7f6f2de89a321f7eae5e942c8668cb50acfd1d.zip
external_llvm-9b7f6f2de89a321f7eae5e942c8668cb50acfd1d.tar.gz
external_llvm-9b7f6f2de89a321f7eae5e942c8668cb50acfd1d.tar.bz2
Instruction::isAssociative() returns true for fmul/fadd if they are tagged "unsafe" mode.
Approved by: Eli and Michael. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168848 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/Instruction.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp
index 4208144..d93c1d7 100644
--- a/lib/VMCore/Instruction.cpp
+++ b/lib/VMCore/Instruction.cpp
@@ -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)