diff options
author | Eli Friedman <efriedma@codeaurora.org> | 2017-03-08 00:56:35 +0000 |
---|---|---|
committer | Eli Friedman <efriedma@codeaurora.org> | 2017-03-08 00:56:35 +0000 |
commit | c2c2e21d77198adfad78cbc11b778021d384ef90 (patch) | |
tree | 83865eac2d3b4879f5333263d5fb64651d751c51 /llvm/lib/CodeGen | |
parent | d8ed207a20df6bd1d29dd86d806181be7fc94e76 (diff) | |
download | bcm5719-llvm-c2c2e21d77198adfad78cbc11b778021d384ef90.tar.gz bcm5719-llvm-c2c2e21d77198adfad78cbc11b778021d384ef90.zip |
[DAGCombine] Simplify ISD::AND in GetDemandedBits.
This helps in cases involving bitfields where an AND is exposed by
legalization.
Differential Revision: https://reviews.llvm.org/D30472
llvm-svn: 297249
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 1abc7049b1c..8bed34497f6 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -7461,6 +7461,9 @@ SDValue DAGCombiner::visitAssertZext(SDNode *N) { /// See if the specified operand can be simplified with the knowledge that only /// the bits specified by Mask are used. If so, return the simpler operand, /// otherwise return a null SDValue. +/// +/// (This exists alongside SimplifyDemandedBits because GetDemandedBits can +/// simplify nodes with multiple uses more aggressively.) SDValue DAGCombiner::GetDemandedBits(SDValue V, const APInt &Mask) { switch (V.getOpcode()) { default: break; @@ -7496,6 +7499,14 @@ SDValue DAGCombiner::GetDemandedBits(SDValue V, const APInt &Mask) { return DAG.getNode(ISD::SRL, SDLoc(V), V.getValueType(), SimplifyLHS, V.getOperand(1)); } + break; + case ISD::AND: { + // X & -1 -> X (ignoring bits which aren't demanded). + ConstantSDNode *AndVal = isConstOrConstSplat(V.getOperand(1)); + if (AndVal && (AndVal->getAPIntValue() & Mask) == Mask) + return V.getOperand(0); + break; + } } return SDValue(); } |