diff options
author | Chris Lattner <sabre@nondot.org> | 2002-10-31 04:24:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-10-31 04:24:23 +0000 |
commit | 6b1c4fcfb5e0c8843054dfc8de62888927fa6ce9 (patch) | |
tree | ad1a6b50ec38018647ec3e8ff01320affa98ef6d | |
parent | f37c34430dd72b1d38c2207cce436ed1612b9995 (diff) |
Can simplify code now with the isCommutative() method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4461 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/iOperators.cpp | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index 20e60cf874..5aa9714eb9 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -133,21 +133,13 @@ const Value *BinaryOperator::getNotArgument(const BinaryOperator *Bop) { // order dependant (SetLT f.e.) the opcode is changed. // bool BinaryOperator::swapOperands() { - if (SetCondInst *SCI = dyn_cast<SetCondInst>(this)) { + if (isCommutative()) + ; // If the instruction is commutative, it is safe to swap the operands + else if (SetCondInst *SCI = dyn_cast<SetCondInst>(this)) iType = SCI->getSwappedCondition(); - std::swap(Operands[0], Operands[1]); - return false; - } + else + return true; // Can't commute operands - switch (getOpcode()) { - // Instructions that don't need opcode modification - case Add: case Mul: - case And: case Xor: - case Or: - // Error on the side of caution - default: - return true; - } std::swap(Operands[0], Operands[1]); return false; } |