diff options
| author | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-03-12 15:58:28 +0000 | 
|---|---|---|
| committer | Simon Pilgrim <llvm-dev@redking.me.uk> | 2019-03-12 15:58:28 +0000 | 
| commit | 9f0a5ca843e106e6ea9a9b233d9662694bb33985 (patch) | |
| tree | 89c57bb25f40e1eba8eac9081041aec8ae57137d /llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | |
| parent | 02e88490c1e0b899abab9097c31aff8667a94f04 (diff) | |
| download | bcm5719-llvm-9f0a5ca843e106e6ea9a9b233d9662694bb33985.tar.gz bcm5719-llvm-9f0a5ca843e106e6ea9a9b233d9662694bb33985.zip | |
[DAGCombine] Pull out repeated demanded bitmask generation. NFCI.
llvm-svn: 355932
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 19 | 
1 files changed, 9 insertions, 10 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8426e3925a1..fc1c97b8e9a 100644 --- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -15420,23 +15420,22 @@ SDValue DAGCombiner::visitSTORE(SDNode *N) {        Value.getValueType().isInteger() &&        (!isa<ConstantSDNode>(Value) ||         !cast<ConstantSDNode>(Value)->isOpaque())) { +    APInt TruncDemandedBits = +        APInt::getLowBitsSet(Value.getScalarValueSizeInBits(), +                             ST->getMemoryVT().getScalarSizeInBits()); +      // See if we can simplify the input to this truncstore with knowledge that      // only the low bits are being used.  For example:      // "truncstore (or (shl x, 8), y), i8"  -> "truncstore y, i8" -    SDValue Shorter = DAG.GetDemandedBits( -        Value, APInt::getLowBitsSet(Value.getScalarValueSizeInBits(), -                                    ST->getMemoryVT().getScalarSizeInBits())); +    SDValue Shorter = DAG.GetDemandedBits(Value, TruncDemandedBits);      AddToWorklist(Value.getNode()); -    if (Shorter.getNode()) -      return DAG.getTruncStore(Chain, SDLoc(N), Shorter, -                               Ptr, ST->getMemoryVT(), ST->getMemOperand()); +    if (Shorter) +      return DAG.getTruncStore(Chain, SDLoc(N), Shorter, Ptr, ST->getMemoryVT(), +                               ST->getMemOperand());      // Otherwise, see if we can simplify the operation with      // SimplifyDemandedBits, which only works if the value has a single use. -    if (SimplifyDemandedBits( -            Value, -            APInt::getLowBitsSet(Value.getScalarValueSizeInBits(), -                                 ST->getMemoryVT().getScalarSizeInBits()))) { +    if (SimplifyDemandedBits(Value, TruncDemandedBits)) {        // Re-visit the store if anything changed and the store hasn't been merged        // with another node (N is deleted) SimplifyDemandedBits will add Value's        // node back to the worklist if necessary, but we also need to re-visit | 

