[llvm-commits] CVS: llvm/lib/VMCore/iOperators.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Oct 30 22:25:01 PST 2002
Changes in directory llvm/lib/VMCore:
iOperators.cpp updated: 1.19 -> 1.20
---
Log message:
Can simplify code now with the isCommutative() method.
---
Diffs of the changes:
Index: llvm/lib/VMCore/iOperators.cpp
diff -u llvm/lib/VMCore/iOperators.cpp:1.19 llvm/lib/VMCore/iOperators.cpp:1.20
--- llvm/lib/VMCore/iOperators.cpp:1.19 Tue Sep 10 14:57:53 2002
+++ llvm/lib/VMCore/iOperators.cpp Wed Oct 30 22:24:23 2002
@@ -133,21 +133,13 @@
// 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;
}
More information about the llvm-commits
mailing list