Skip to content

Commit 325ea8c

Browse files
committed
[LV] Preserve m_ZeroInt, address review
1 parent 07be4a1 commit 325ea8c

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

llvm/lib/Transforms/Vectorize/EVLIndVarSimplify.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ bool EVLIndVarSimplifyImpl::run(Loop &L) {
186186
Value *TC = nullptr;
187187
auto IntrinsicMatch = m_Intrinsic<Intrinsic::experimental_get_vector_length>(
188188
m_Value(RemTC), m_SpecificInt(VF),
189-
/*Scalable=*/m_One());
189+
/*Scalable=*/m_SpecificInt(1));
190190
for (PHINode &PN : BB->phis()) {
191191
if (&PN == IndVar)
192192
continue;

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,19 +149,21 @@ struct is_zero_int {
149149
bool isValue(const APInt &C) const { return C.isZero(); }
150150
};
151151

152-
struct is_one_int {
152+
struct is_one {
153153
bool isValue(const APInt &C) const { return C.isOne(); }
154154
};
155155

156156
/// Match an integer 0 or a vector with all elements equal to 0.
157157
/// For vectors, this includes constants with undefined elements.
158+
/// The reason for not naming this m_Zero() is because PatternMatch::m_Zero()
159+
/// also matches null constants.
158160
inline int_pred_ty<is_zero_int> m_ZeroInt() {
159161
return int_pred_ty<is_zero_int>();
160162
}
161163

162164
/// Match an integer 1 or a vector with all elements equal to 1.
163165
/// For vectors, this includes constants with undefined elements.
164-
inline int_pred_ty<is_one_int> m_OneInt() { return int_pred_ty<is_one_int>(); }
166+
inline int_pred_ty<is_one> m_One() { return int_pred_ty<is_one>(); }
165167

166168
/// Matching combinators
167169
template <typename LTy, typename RTy> struct match_combine_or {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,7 +1134,7 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
11341134
return Def->replaceAllUsesWith(
11351135
Builder.createLogicalAnd(X, Builder.createLogicalAnd(Y, Z)));
11361136

1137-
if (match(Def, m_c_Mul(m_VPValue(A), m_OneInt())))
1137+
if (match(Def, m_c_Mul(m_VPValue(A), m_One())))
11381138
return Def->replaceAllUsesWith(A);
11391139

11401140
if (match(Def, m_c_Mul(m_VPValue(A), m_ZeroInt())))
@@ -1176,14 +1176,14 @@ static void simplifyRecipe(VPRecipeBase &R, VPTypeAnalysis &TypeInfo) {
11761176
}
11771177

11781178
// Remove redundant DerviedIVs, that is 0 + A * 1 -> A and 0 + 0 * x -> 0.
1179-
if ((match(Def, m_DerivedIV(m_ZeroInt(), m_VPValue(A), m_OneInt())) ||
1179+
if ((match(Def, m_DerivedIV(m_ZeroInt(), m_VPValue(A), m_One())) ||
11801180
match(Def, m_DerivedIV(m_ZeroInt(), m_ZeroInt(), m_VPValue()))) &&
11811181
TypeInfo.inferScalarType(Def->getOperand(1)) ==
11821182
TypeInfo.inferScalarType(Def))
11831183
return Def->replaceAllUsesWith(Def->getOperand(1));
11841184

11851185
if (match(Def, m_VPInstruction<VPInstruction::WideIVStep>(m_VPValue(X),
1186-
m_OneInt()))) {
1186+
m_One()))) {
11871187
Type *WideStepTy = TypeInfo.inferScalarType(Def);
11881188
if (TypeInfo.inferScalarType(X) != WideStepTy)
11891189
X = Builder.createWidenCast(Instruction::Trunc, X, WideStepTy);

llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ void UnrollState::unrollHeaderPHIByUF(VPHeaderPHIRecipe *R,
238238
if (Part != 1)
239239
continue;
240240
VPValue *StartV;
241-
if (match(VPI->getOperand(2), m_OneInt())) {
241+
if (match(VPI->getOperand(2), m_One())) {
242242
StartV = VPI->getOperand(1);
243243
} else {
244244
auto *C = VPI->clone();

llvm/lib/Transforms/Vectorize/VPlanUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ bool vputils::isHeaderMask(const VPValue *V, VPlan &Plan) {
6565
VPValue *A, *B;
6666
using namespace VPlanPatternMatch;
6767

68-
if (match(V, m_ActiveLaneMask(m_VPValue(A), m_VPValue(B), m_OneInt())))
68+
if (match(V, m_ActiveLaneMask(m_VPValue(A), m_VPValue(B), m_One())))
6969
return B == Plan.getTripCount() &&
70-
(match(A, m_ScalarIVSteps(m_Specific(Plan.getCanonicalIV()),
71-
m_OneInt(), m_Specific(&Plan.getVF()))) ||
70+
(match(A, m_ScalarIVSteps(m_Specific(Plan.getCanonicalIV()), m_One(),
71+
m_Specific(&Plan.getVF()))) ||
7272
IsWideCanonicalIV(A));
7373

7474
return match(V, m_Binary<Instruction::ICmp>(m_VPValue(A), m_VPValue(B))) &&

0 commit comments

Comments
 (0)