diff options
author | Dan Gohman <gohman@apple.com> | 2010-02-22 22:05:18 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-02-22 22:05:18 +0000 |
commit | d97439d1e5a04a580c48b98512885866dcc83e2a (patch) | |
tree | e582f92e27371d14e54cc0ac3929f8c03e9bc9b0 /lib | |
parent | 2ec5e49a2ba3c8a6ea53c13d4393d57ad1dbb64b (diff) | |
download | external_llvm-d97439d1e5a04a580c48b98512885866dcc83e2a.zip external_llvm-d97439d1e5a04a580c48b98512885866dcc83e2a.tar.gz external_llvm-d97439d1e5a04a580c48b98512885866dcc83e2a.tar.bz2 |
Use Instruction::isCommutative instead of duplicating it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96807 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 25 |
1 files changed, 1 insertions, 24 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index b3df371..c79eb7e 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/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. |