summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2010-02-22 22:05:18 +0000
committerDan Gohman <gohman@apple.com>2010-02-22 22:05:18 +0000
commit6eeabaad2bab74d7064574fb053e5e099a4f000c (patch)
tree1d3e47ea5b4ac68447164141ea10ce01313cbccb /llvm/lib/VMCore/ConstantFold.cpp
parent5ddd4aca97b64453d2ca879d543c22f3608615a6 (diff)
downloadbcm5719-llvm-6eeabaad2bab74d7064574fb053e5e099a4f000c.tar.gz
bcm5719-llvm-6eeabaad2bab74d7064574fb053e5e099a4f000c.zip
Use Instruction::isCommutative instead of duplicating it.
llvm-svn: 96807
Diffstat (limited to 'llvm/lib/VMCore/ConstantFold.cpp')
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp25
1 files changed, 1 insertions, 24 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index b3df371d2c6..c79eb7ef2c9 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -1364,31 +1364,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode,
} else if (isa<ConstantExpr>(C2)) {
// If C2 is a constant expr and C1 isn't, flop them around and fold the
// other way if possible.
- switch (Opcode) {
- case Instruction::Add:
- case Instruction::FAdd:
- case Instruction::Mul:
- case Instruction::FMul:
- case Instruction::And:
- case Instruction::Or:
- case Instruction::Xor:
- // No change of opcode required.
+ if (Instruction::isCommutative(Opcode))
return ConstantFoldBinaryInstruction(Opcode, C2, C1);
-
- case Instruction::Shl:
- case Instruction::LShr:
- case Instruction::AShr:
- case Instruction::Sub:
- case Instruction::FSub:
- case Instruction::SDiv:
- case Instruction::UDiv:
- case Instruction::FDiv:
- case Instruction::URem:
- case Instruction::SRem:
- case Instruction::FRem:
- default: // These instructions cannot be flopped around.
- break;
- }
}
// i1 can be simplified in many cases.
OpenPOWER on IntegriCloud