[PATCH] D109515: [AggressiveInstCombine] Add `udiv` and `urem` instrs to TruncInstCombine DAG
Anton Afanasyev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 10 08:29:05 PDT 2021
anton-afanasyev added inline comments.
================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp:318-319
+ KnownBits Known = computeKnownBits(Op);
+ MinBitWidth =
+ std::max(Known.getMaxValue().getActiveBits(), MinBitWidth);
+ if (MinBitWidth >= OrigBitWidth)
----------------
lebedev.ri wrote:
> Hm, if you swap arguments around, does it lead to better clang-format?
No(
It fixes even my "legal" trials like this one:
```
MinBitWidth = std::max(Known.getMaxValue().getActiveBits(),
MinBitWidth);
```
================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp:151
+ // 2. phi node(and loop handling)
// ...
return false;
----------------
lebedev.ri wrote:
> sdiv, srem; see b289dc530632613edb3eb067895c1981cb77ccd0.
Ok, added to todo.
================
Comment at: llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp:314-323
+ KnownBits KnownLHS = computeKnownBits(I->getOperand(0));
+ unsigned MinBitWidth = KnownLHS.getMaxValue().getActiveBits();
+ if (MinBitWidth >= OrigBitWidth)
+ return nullptr;
+ KnownBits KnownRHS = computeKnownBits(I->getOperand(1));
+ MinBitWidth =
+ std::max(MinBitWidth, KnownRHS.getMaxValue().getActiveBits());
----------------
lebedev.ri wrote:
>
Ok, done.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109515/new/
https://reviews.llvm.org/D109515
More information about the llvm-commits
mailing list