[IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static version.

llvm-svn: 298826
This commit is contained in:
Craig Topper 2017-03-26 23:23:29 +00:00
parent a2c4e4b929
commit 224b19d626
2 changed files with 5 additions and 13 deletions

View File

@ -382,8 +382,11 @@ public:
///
/// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
///
bool isAssociative() const;
static bool isAssociative(unsigned op);
bool isAssociative() const LLVM_READONLY;
static bool isAssociative(unsigned Opcode) {
return Opcode == And || Opcode == Or || Opcode == Xor ||
Opcode == Add || Opcode == Mul;
}
/// Return true if the instruction is commutative:
///

View File

@ -545,17 +545,6 @@ bool Instruction::mayThrow() const {
return isa<ResumeInst>(this);
}
/// Return true if the instruction is associative:
///
/// Associative operators satisfy: x op (y op z) === (x op y) op z
///
/// In LLVM, the Add, Mul, And, Or, and Xor operators are associative.
///
bool Instruction::isAssociative(unsigned Opcode) {
return Opcode == And || Opcode == Or || Opcode == Xor ||
Opcode == Add || Opcode == Mul;
}
bool Instruction::isAssociative() const {
unsigned Opcode = getOpcode();
if (isAssociative(Opcode))