diff options
author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-07-11 09:56:41 +0000 |
---|---|---|
committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2018-07-11 09:56:41 +0000 |
commit | 075b04a55f74daf3a75944fe91dc210974a6f703 (patch) | |
tree | 1a65804a027fabb4d1394aa4839c3ebbe1ca8f69 /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | 2b3a4f9c9b0703a4f27c33139d32844378b26211 (diff) | |
download | bcm5719-llvm-075b04a55f74daf3a75944fe91dc210974a6f703.tar.gz bcm5719-llvm-075b04a55f74daf3a75944fe91dc210974a6f703.zip |
[SelectionDAG] Add constant buildvector support to isKnownNeverZero
This allows us to use SelectionDAG::isKnownNeverZero in DAGCombiner::visitREM (visitSDIVLike/visitUDIVLike handle the checking for constants).
llvm-svn: 336779
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 4b02b0cf9c5..9870f21666f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -3626,12 +3626,18 @@ bool SelectionDAG::isKnownNeverZero(SDValue Op) const { assert(!Op.getValueType().isFloatingPoint() && "Floating point types unsupported - use isKnownNeverZeroFloat"); + // If the value is a constant, we can obviously see if it is a zero or not. + if (ISD::matchUnaryPredicate( + Op, [](ConstantSDNode *C) { return !C->isNullValue(); })) + return true; + // TODO: Recognize more cases here. switch (Op.getOpcode()) { default: break; case ISD::OR: - if (const ConstantSDNode *C = dyn_cast<ConstantSDNode>(Op.getOperand(1))) - return !C->isNullValue(); + if (isKnownNeverZero(Op.getOperand(1)) || + isKnownNeverZero(Op.getOperand(0))) + return true; break; } |