[llvm] r372637 - [InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment
Roman Lebedev via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 23 11:21:14 PDT 2019
Author: lebedevri
Date: Mon Sep 23 11:21:14 2019
New Revision: 372637
URL: http://llvm.org/viewvc/llvm-project?rev=372637&view=rev
Log:
[InstCombine] dropRedundantMaskingOfLeftShiftInput(): improve comment
Modified:
llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
Modified: llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp?rev=372637&r1=372636&r2=372637&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp (original)
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineShifts.cpp Mon Sep 23 11:21:14 2019
@@ -171,8 +171,8 @@ dropRedundantMaskingOfLeftShiftInput(Bin
// 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(Bin
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()
More information about the llvm-commits
mailing list