[PATCH] D58626: [DAG] Fix constant store folding to handle non-byte sizes.
Clement Courbet via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 25 08:04:58 PST 2019
courbet added inline comments.
================
Comment at: llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:15436
// be used as data sinks.
- if (STBase.contains(STByteSize, ChainBase, ChainByteSize, DAG)) {
+ if (STBase.contains((STBitSize+7)/8, ChainBase, (ChainBitSize+7)/8, DAG)) {
CombineTo(ST1, ST1->getChain());
----------------
This is overly optimistic: for example, this will return true for STBitSize = 1 and ChainBitSize= 2 if both are at offset 0
What about passing size in bits to BaseIndexOffset::contains() and letting it do the computation in bits:
```
bool BaseIndexOffset::contains(int64_t BitSize, const BaseIndexOffset &Other,
int64_t OtherBitSize, const SelectionDAG &DAG,
int64_t &Offset) const {
if (!equalBaseIndex(Other, DAG, Offset))
return false;
if (Offset >= 0) {
// Other is after *this:
// [-------*this---------]
// [---Other--]
// ==Offset==>
return 8 * Offset + OtherBitSize <= BitSize;
}
// Other starts strictly before *this, it cannot be fully contained.
// [-------*this---------]
// [--Other--]
return false;
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58626/new/
https://reviews.llvm.org/D58626
More information about the llvm-commits
mailing list