From: Roman Lebedev Date: Mon, 23 Sep 2019 18:21:14 +0000 (+0000) Subject: [InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f1a42a614d9fdefc18dff35dc01db1da9bd9cf5e;p=llvm [InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@372637 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/InstCombine/InstCombineShifts.cpp b/lib/Transforms/InstCombine/InstCombineShifts.cpp index 2dea4c45cbd..ba77696f1f1 100644 --- a/lib/Transforms/InstCombine/InstCombineShifts.cpp +++ b/lib/Transforms/InstCombine/InstCombineShifts.cpp @@ -171,8 +171,8 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift, // But for a mask we need to get rid of old masking instruction. if (!Masked->hasOneUse()) return nullptr; // Else we can't perform the fold. - // We should produce compute the mask in wider type, and truncate later! - // Get type twice as wide element-wise (same number of elements!). + // The mask must be computed in a type twice as wide to ensure + // that no bits are lost if the sum-of-shifts is wider than the base type. Type *ExtendedScalarTy = Type::getIntNTy(Ty->getContext(), 2 * BitWidth); Type *ExtendedTy = Ty->isVectorTy() @@ -211,8 +211,8 @@ dropRedundantMaskingOfLeftShiftInput(BinaryOperator *OuterShift, return nullptr; // Else we can't perform the fold. Type *Ty = X->getType(); unsigned BitWidth = Ty->getScalarSizeInBits(); - // We should produce compute the mask in wider type, and truncate later! - // Get type twice as wide element-wise (same number of elements!). + // The mask must be computed in a type twice as wide to ensure + // that no bits are lost if the sum-of-shifts is wider than the base type. Type *ExtendedScalarTy = Type::getIntNTy(Ty->getContext(), 2 * BitWidth); Type *ExtendedTy = Ty->isVectorTy()