Changes in directory llvm/lib/VMCore:
ConstantFolding.cpp updated: 1.78 -> 1.79 --- Log message: implement constant folding of ==/!= on constant packed, simplify some code. --- Diffs of the changes: (+11 -3) ConstantFolding.cpp | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.78 llvm/lib/VMCore/ConstantFolding.cpp:1.79 --- llvm/lib/VMCore/ConstantFolding.cpp:1.78 Tue Jan 3 20:15:02 2006 +++ llvm/lib/VMCore/ConstantFolding.cpp Tue Jan 3 20:20:54 2006 @@ -385,6 +385,14 @@ 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 @@ 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; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits