diff options
author | Chris Lattner <sabre@nondot.org> | 2006-01-04 02:20:54 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-01-04 02:20:54 +0000 |
commit | 84e1064f4584c20b839b9172c5c26c20b6ffb2fe (patch) | |
tree | 1035a057d7825a891785e05bc24e4664e35bdbad /lib/VMCore | |
parent | d2a7ea45b0603aeeb4921ab3b7e39aa07ca3bd77 (diff) | |
download | external_llvm-84e1064f4584c20b839b9172c5c26c20b6ffb2fe.zip external_llvm-84e1064f4584c20b839b9172c5c26c20b6ffb2fe.tar.gz external_llvm-84e1064f4584c20b839b9172c5c26c20b6ffb2fe.tar.bz2 |
implement constant folding of ==/!= on constant packed, simplify some code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25074 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/ConstantFold.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index e6a2715..4ac5292 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -385,6 +385,14 @@ struct ConstantPackedRules return 0; } static Constant *EqualTo(const ConstantPacked *V1, const ConstantPacked *V2) { + for (unsigned i = 0, e = V1->getNumOperands(); i != e; ++i) { + Constant *C = + ConstantExpr::getSetEQ(const_cast<Constant*>(V1->getOperand(i)), + const_cast<Constant*>(V2->getOperand(i))); + if (ConstantBool *CB = dyn_cast<ConstantBool>(C)) + return CB; + } + // Otherwise, could not decide from any element pairs. return 0; } }; @@ -951,15 +959,15 @@ Constant *llvm::ConstantFoldBinaryInstruction(unsigned Opcode, case Instruction::SetGT: C = ConstRules::get(V1, V2).lessthan(V2, V1);break; case Instruction::SetNE: // V1 != V2 === !(V1 == V2) C = ConstRules::get(V1, V2).equalto(V1, V2); - if (C) return ConstantExpr::get(Instruction::Xor, C, ConstantBool::True); + if (C) return ConstantExpr::getNot(C); break; case Instruction::SetLE: // V1 <= V2 === !(V2 < V1) C = ConstRules::get(V1, V2).lessthan(V2, V1); - if (C) return ConstantExpr::get(Instruction::Xor, C, ConstantBool::True); + if (C) return ConstantExpr::getNot(C); break; case Instruction::SetGE: // V1 >= V2 === !(V1 < V2) C = ConstRules::get(V1, V2).lessthan(V1, V2); - if (C) return ConstantExpr::get(Instruction::Xor, C, ConstantBool::True); + if (C) return ConstantExpr::getNot(C); break; } |