From: Craig Topper Date: Sun, 26 Mar 2017 23:23:29 +0000 (+0000) Subject: [IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8a88c236128ecabd4ce72f0f42321417ce40cde1;p=llvm [IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static version. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298826 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/IR/Instruction.h b/include/llvm/IR/Instruction.h index c1be9da498d..b0bb81e9de1 100644 --- a/include/llvm/IR/Instruction.h +++ b/include/llvm/IR/Instruction.h @@ -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: /// diff --git a/lib/IR/Instruction.cpp b/lib/IR/Instruction.cpp index fc8a0566ab5..8674342a88a 100644 --- a/lib/IR/Instruction.cpp +++ b/lib/IR/Instruction.cpp @@ -545,17 +545,6 @@ bool Instruction::mayThrow() const { return isa(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))