[llvm] r298826 - [IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static version.
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 26 16:23:29 PDT 2017
Author: ctopper
Date: Sun Mar 26 18:23:29 2017
New Revision: 298826
URL: http://llvm.org/viewvc/llvm-project?rev=298826&view=rev
Log:
[IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static version.
Modified:
llvm/trunk/include/llvm/IR/Instruction.h
llvm/trunk/lib/IR/Instruction.cpp
Modified: llvm/trunk/include/llvm/IR/Instruction.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instruction.h?rev=298826&r1=298825&r2=298826&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instruction.h (original)
+++ llvm/trunk/include/llvm/IR/Instruction.h Sun Mar 26 18:23:29 2017
@@ -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:
///
Modified: llvm/trunk/lib/IR/Instruction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Instruction.cpp?rev=298826&r1=298825&r2=298826&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Instruction.cpp (original)
+++ llvm/trunk/lib/IR/Instruction.cpp Sun Mar 26 18:23:29 2017
@@ -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))
More information about the llvm-commits
mailing list