summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2006-05-31 06:08:35 +0000
committerEvan Cheng <evan.cheng@apple.com>2006-05-31 06:08:35 +0000
commit64d28460170910ae7dddcc4e227d5b46d3135d49 (patch)
tree1da13eea231e4715c44623cfc1739940087f042c /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
parent03977ec9b179ffbbc7b66505a9071547e9bb5e29 (diff)
downloadbcm5719-llvm-64d28460170910ae7dddcc4e227d5b46d3135d49.tar.gz
bcm5719-llvm-64d28460170910ae7dddcc4e227d5b46d3135d49.zip
visitVBinOp: Can't fold divide by zero!
llvm-svn: 28584
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index c05c976f390..938e17a084f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2778,6 +2778,14 @@ SDOperand DAGCombiner::visitVBinOp(SDNode *N, ISD::NodeType IntOp,
RHSOp.getOpcode() != ISD::Constant &&
RHSOp.getOpcode() != ISD::ConstantFP))
break;
+ // Can't fold divide by zero.
+ if (N->getOpcode() == ISD::VSDIV || N->getOpcode() == ISD::VUDIV) {
+ if ((RHSOp.getOpcode() == ISD::Constant &&
+ cast<ConstantSDNode>(RHSOp.Val)->isNullValue()) ||
+ (RHSOp.getOpcode() == ISD::ConstantFP &&
+ !cast<ConstantFPSDNode>(RHSOp.Val)->getValue()))
+ break;
+ }
Ops.push_back(DAG.getNode(ScalarOp, EltType, LHSOp, RHSOp));
AddToWorkList(Ops.back().Val);
assert((Ops.back().getOpcode() == ISD::UNDEF ||
OpenPOWER on IntegriCloud