[PATCH] D60460: [SelectionDAG] Use KnownBits::computeForAddSub in SelectionDAG::computeKnownBits

Bjorn Pettersson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 10 04:48:16 PDT 2019


bjope added inline comments.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp:2948
         Known.Zero.setBits(1, KnownZeroLow);
       break;
     }
----------------
nikic wrote:
> I think it would make more sense to move the computeForAddSub calculation above this branch, and then do something like this here:
> 
> ```
> // With ADDE and ADDCARRY a carry bit may be added, so we can only use
> // this information if we know that the low bit is clear.
> if (!lowBitSet(Known.Zero)) { // How do you write this operation with APInt?
>   Known.One.clearAllBits();
>   Known.Zero.clearAllBits();
>   break;
> }
> 
> Known.Zero.clearBit(0);
> ```
> 
> This allows us to use the full known bits result, just without the low bit, if it is possible.
Or maybe I can use computeForAddSub a second time, simulating an add of the carry bit
```
    // With ADDE and ADDCARRY, a carry bit may be added in.
    if (Opcode == ISD::ADDE || Opcode == ISD::ADDCARRY) {
      // TODO: Can we compute known bits for the carry bit? For now we set it to
      // unknown.
      Known2.setAllZero();
      Known2.Zero.clearBit(0);
      Known = KnownBits::computeForAddSub(/* IsAdd */ true, /* NSW */ false,
                                          Known, Known2);
    }

```


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60460/new/

https://reviews.llvm.org/D60460





More information about the llvm-commits mailing list