Instruction *I = dyn_cast<Instruction>(V);
if (!I) return false;
- // If this is the opposite shift, we can directly reuse the input of the shift
- // if the needed bits are already zero in the input. This allows us to reuse
- // the value which means that we don't care if the shift has multiple uses.
- // TODO: Handle opposite shift by exact value.
- ConstantInt *CI = nullptr;
- if ((IsLeftShift && match(I, m_LShr(m_Value(), m_ConstantInt(CI)))) ||
- (!IsLeftShift && match(I, m_Shl(m_Value(), m_ConstantInt(CI))))) {
- if (CI->getValue() == NumBits) {
- // TODO: Check that the input bits are already zero with MaskedValueIsZero
-#if 0
- // If this is a truncate of a logical shr, we can truncate it to a smaller
- // lshr iff we know that the bits we would otherwise be shifting in are
- // already zeros.
- uint32_t OrigBitWidth = OrigTy->getScalarSizeInBits();
- uint32_t BitWidth = Ty->getScalarSizeInBits();
- if (MaskedValueIsZero(I->getOperand(0),
- APInt::getHighBitsSet(OrigBitWidth, OrigBitWidth-BitWidth)) &&
- CI->getLimitedValue(BitWidth) < BitWidth) {
- return CanEvaluateTruncated(I->getOperand(0), Ty);
- }
-#endif
-
- }
- }
-
// We can't mutate something that has multiple uses: doing so would
// require duplicating the instruction in general, which isn't profitable.
if (!I->hasOneUse()) return false;