From: Dan Gohman Date: Mon, 22 Feb 2010 22:05:18 +0000 (+0000) Subject: Use Instruction::isCommutative instead of duplicating it. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d97439d1e5a04a580c48b98512885866dcc83e2a;p=oota-llvm.git Use Instruction::isCommutative instead of duplicating it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96807 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index b3df371d2c6..c79eb7ef2c9 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1364,31 +1364,8 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, } else if (isa(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.