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
This commit is contained in:
Shuxin Yang
2012-11-29 01:47:31 +00:00
parent 89bea17af2
commit 9b7f6f2de8
3 changed files with 47 additions and 1 deletions

View 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)