[PATCH] D109288: [AggresiveInstCombine] Add wrapper calls for `KnownBits` computing
Anton Afanasyev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 7 06:46:06 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8c0a1940c1d8: [AggresiveInstCombine] Add wrapper calls for `KnownBits` computing (authored by anton-afanasyev).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109288/new/
https://reviews.llvm.org/D109288
Files:
llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombineInternal.h
llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
Index: llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
===================================================================
--- llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
+++ llvm/lib/Transforms/AggressiveInstCombine/TruncInstCombine.cpp
@@ -288,19 +288,19 @@
for (auto &Itr : InstInfoMap) {
Instruction *I = Itr.first;
if (I->isShift()) {
- KnownBits KnownRHS = computeKnownBits(I->getOperand(1), DL);
+ KnownBits KnownRHS = computeKnownBits(I->getOperand(1));
unsigned MinBitWidth = KnownRHS.getMaxValue()
.uadd_sat(APInt(OrigBitWidth, 1))
.getLimitedValue(OrigBitWidth);
if (MinBitWidth == OrigBitWidth)
return nullptr;
if (I->getOpcode() == Instruction::LShr) {
- KnownBits KnownLHS = computeKnownBits(I->getOperand(0), DL);
+ KnownBits KnownLHS = computeKnownBits(I->getOperand(0));
MinBitWidth =
std::max(MinBitWidth, KnownLHS.getMaxValue().getActiveBits());
}
if (I->getOpcode() == Instruction::AShr) {
- unsigned NumSignBits = ComputeNumSignBits(I->getOperand(0), DL);
+ unsigned NumSignBits = ComputeNumSignBits(I->getOperand(0));
MinBitWidth = std::max(MinBitWidth, OrigBitWidth - NumSignBits + 1);
}
if (MinBitWidth >= OrigBitWidth)
Index: llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombineInternal.h
===================================================================
--- llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombineInternal.h
+++ llvm/lib/Transforms/AggressiveInstCombine/AggressiveInstCombineInternal.h
@@ -17,6 +17,8 @@
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
+#include "llvm/Analysis/ValueTracking.h"
+#include "llvm/Support/KnownBits.h"
using namespace llvm;
@@ -104,6 +106,16 @@
/// to be reduced.
Type *getBestTruncatedType();
+ KnownBits computeKnownBits(const Value *V) const {
+ return llvm::computeKnownBits(V, DL, /*Depth=*/0, /*AC=*/nullptr,
+ /*CtxI=*/nullptr, &DT);
+ }
+
+ unsigned ComputeNumSignBits(const Value *V) const {
+ return llvm::ComputeNumSignBits(V, DL, /*Depth=*/0, /*AC=*/nullptr,
+ /*CtxI=*/nullptr, &DT);
+ }
+
/// Given a \p V value and a \p SclTy scalar type return the generated reduced
/// value of \p V based on the type \p SclTy.
///
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109288.371062.patch
Type: text/x-patch
Size: 2496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210907/7f09d433/attachment.bin>
More information about the llvm-commits
mailing list