summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2018-10-31 14:18:57 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2018-10-31 14:18:57 +0000
commitd0080c3a5f9b9f2143505bf1aca4ce5a0303da25 (patch)
tree06a778bdb04abb3f281338675b7c3d68bf4f5568 /llvm/lib/CodeGen
parent103a0559b752440e62323edbec47a59ae2dd24ef (diff)
downloadbcm5719-llvm-d0080c3a5f9b9f2143505bf1aca4ce5a0303da25.tar.gz
bcm5719-llvm-d0080c3a5f9b9f2143505bf1aca4ce5a0303da25.zip
[DAGCombiner] Fold 0 div/rem X to 0
Reviewers: RKSimon, spatel, javed.absar, craig.topper, t.p.northover Reviewed By: RKSimon Subscribers: craig.topper, llvm-commits Differential Revision: https://reviews.llvm.org/D52504 llvm-svn: 345721
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index fba2aa9cb52..e6ea4898717 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3128,8 +3128,11 @@ static SDValue simplifyDivRem(SDNode *N, SelectionDAG &DAG) {
if (N0.isUndef())
return DAG.getConstant(0, DL, VT);
- // TODO: 0 / X -> 0
- // TODO: 0 % X -> 0
+ // 0 / X -> 0
+ // 0 % X -> 0
+ ConstantSDNode *N0C = isConstOrConstSplat(N0);
+ if (N0C && N0C->isNullValue())
+ return N0;
// X / X -> 1
// X % X -> 0
OpenPOWER on IntegriCloud