Changes in directory llvm/lib/CodeGen/SelectionDAG:
SelectionDAG.cpp updated: 1.300 -> 1.301 --- Log message: Implement folding of a bunch of binops with undef --- Diffs of the changes: (+46 -0) SelectionDAG.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 46 insertions(+) Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp diff -u llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.300 llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.301 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:1.300 Sat Apr 15 18:38:00 2006 +++ llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Apr 20 00:39:12 2006 @@ -1367,6 +1367,52 @@ } } } + + // Canonicalize an UNDEF to the RHS, even over a constant. + if (N1.getOpcode() == ISD::UNDEF) { + if (isCommutativeBinOp(Opcode)) { + std::swap(N1, N2); + } else { + switch (Opcode) { + case ISD::FP_ROUND_INREG: + case ISD::SIGN_EXTEND_INREG: + case ISD::SUB: + case ISD::FSUB: + case ISD::FDIV: + case ISD::FREM: + return N1; // fold op(undef, arg2) -> undef + case ISD::UDIV: + case ISD::SDIV: + case ISD::UREM: + case ISD::SREM: + return getConstant(0, VT); // fold op(undef, arg2) -> 0 + } + } + } + + // Fold a bunch of operators that + if (N2.getOpcode() == ISD::UNDEF) { + switch (Opcode) { + case ISD::ADD: + case ISD::SUB: + case ISD::FADD: + case ISD::FSUB: + case ISD::FMUL: + case ISD::FDIV: + case ISD::FREM: + case ISD::UDIV: + case ISD::SDIV: + case ISD::UREM: + case ISD::SREM: + case ISD::XOR: + return N2; // fold op(arg1, undef) -> undef + case ISD::MUL: + case ISD::AND: + return getConstant(0, VT); // fold op(arg1, undef) -> 0 + case ISD::OR: + return getConstant(MVT::getIntVTBitMask(VT), VT); + } + } // Finally, fold operations that do not require constants. switch (Opcode) { _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits