[llvm] 46a7346 - [ValueTracking] computeKnownBitsFromShiftOperator - always return with Known2 containing the shifted value source. NFCI.
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 10 09:15:58 PST 2020
Author: Simon Pilgrim
Date: 2020-11-10T17:03:17Z
New Revision: 46a734621dc4b38db78156fcd769864f7ef8ac18
URL: https://github.com/llvm/llvm-project/commit/46a734621dc4b38db78156fcd769864f7ef8ac18
DIFF: https://github.com/llvm/llvm-project/commit/46a734621dc4b38db78156fcd769864f7ef8ac18.diff
LOG: [ValueTracking] computeKnownBitsFromShiftOperator - always return with Known2 containing the shifted value source. NFCI.
As detailed on D90479, in most circumstances we will always call computeKnownBits for Op0, so always perform this by pulling out the duplicate calls.
Added:
Modified:
llvm/lib/Analysis/ValueTracking.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index ce9174bbcdcf..5ff4fcb5492d 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -978,7 +978,8 @@ static void computeKnownBitsFromAssume(const Value *V, KnownBits &Known,
/// Compute known bits from a shift operator, including those with a
/// non-constant shift amount. Known is the output of this function. Known2 is a
-/// pre-allocated temporary with the same bit width as Known. KZF and KOF are
+/// pre-allocated temporary with the same bit width as Known and on return
+/// contains the known bit of the shift value source. KZF and KOF are
/// operator-specific functions that, given the known-zero or known-one bits
/// respectively, and a shift amount, compute the implied known-zero or
/// known-one bits of the shift operator's result respectively for that shift
@@ -990,14 +991,14 @@ static void computeKnownBitsFromShiftOperator(
function_ref<APInt(const APInt &, unsigned)> KZF,
function_ref<APInt(const APInt &, unsigned)> KOF) {
unsigned BitWidth = Known.getBitWidth();
-
+ computeKnownBits(I->getOperand(0), DemandedElts, Known2, Depth + 1, Q);
computeKnownBits(I->getOperand(1), DemandedElts, Known, Depth + 1, Q);
+
if (Known.isConstant()) {
unsigned ShiftAmt = Known.getConstant().getLimitedValue(BitWidth - 1);
-
- computeKnownBits(I->getOperand(0), DemandedElts, Known2, Depth + 1, Q);
Known.Zero = KZF(Known2.Zero, ShiftAmt);
Known.One = KOF(Known2.One, ShiftAmt);
+
// If the known bits conflict, this must be an overflowing left shift, so
// the shift result is poison. We can return anything we want. Choose 0 for
// the best folding opportunity.
@@ -1040,8 +1041,6 @@ static void computeKnownBitsFromShiftOperator(
return;
}
- computeKnownBits(I->getOperand(0), DemandedElts, Known2, Depth + 1, Q);
-
Known.Zero.setAllBits();
Known.One.setAllBits();
for (unsigned ShiftAmt = 0; ShiftAmt < BitWidth; ++ShiftAmt) {
More information about the llvm-commits
mailing list