summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 4c2135e665d..b228f1e3cbb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -2463,6 +2463,9 @@ SDValue DAGCombiner::visitSDIV(SDNode *N) {
// X / undef -> undef
if (N1.isUndef())
return N1;
+ // X / 0 --> undef (we don't need to preserve faults!)
+ if (N1C && N1C->isNullValue())
+ return DAG.getUNDEF(VT);
return SDValue();
}
@@ -2538,6 +2541,9 @@ SDValue DAGCombiner::visitUDIV(SDNode *N) {
// X / undef -> undef
if (N1.isUndef())
return N1;
+ // X / 0 --> undef (we don't need to preserve faults!)
+ if (N1C && N1C->isNullValue())
+ return DAG.getUNDEF(VT);
return SDValue();
}
@@ -2618,7 +2624,10 @@ SDValue DAGCombiner::visitREM(SDNode *N) {
// X % undef -> undef
if (N1.isUndef())
return N1;
-
+ // X % 0 --> undef (we don't need to preserve faults!)
+ if (N1C && N1C->isNullValue())
+ return DAG.getUNDEF(VT);
+
return SDValue();
}
OpenPOWER on IntegriCloud