summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Bolvansky <david.bolvansky@gmail.com>2018-10-30 09:07:22 +0000
committerDavid Bolvansky <david.bolvansky@gmail.com>2018-10-30 09:07:22 +0000
commitdfdbb038e8ea0a46b7ad04b6ad6febb3f38d25c4 (patch)
tree816e6b08e98eed34179c2ec2d1e920ce1d92d22f /llvm/lib
parentda7817164354f29ec8ab79aad52e9004b3c1494c (diff)
downloadbcm5719-llvm-dfdbb038e8ea0a46b7ad04b6ad6febb3f38d25c4.tar.gz
bcm5719-llvm-dfdbb038e8ea0a46b7ad04b6ad6febb3f38d25c4.zip
[DAGCombiner] Improve X div/rem Y fold if single bit element type
Summary: Tests by @spatel, thanks Reviewers: spatel, RKSimon Reviewed By: spatel Subscribers: sdardis, atanasyan, llvm-commits, spatel Differential Revision: https://reviews.llvm.org/D52668 llvm-svn: 345575
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 906223a624c..64c7dca0f6e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -3138,11 +3138,12 @@ static SDValue simplifyDivRem(SDNode *N, SelectionDAG &DAG) {
// X / 1 -> X
// X % 1 -> 0
- if (N1C && N1C->isOne())
- return IsDiv ? N0 : DAG.getConstant(0, DL, VT);
// If this is a boolean op (single-bit element type), we can't have
// division-by-zero or remainder-by-zero, so assume the divisor is 1.
- // Similarly, if we're zero-extending a boolean divisor, then assume it's a 1.
+ // TODO: Similarly, if we're zero-extending a boolean divisor, then assume
+ // it's a 1.
+ if ((N1C && N1C->isOne()) || (VT.getScalarType() == MVT::i1))
+ return IsDiv ? N0 : DAG.getConstant(0, DL, VT);
return SDValue();
}
OpenPOWER on IntegriCloud