Skip to content

Commit b078dc2

Browse files
committed
[VPlan/PM] Remove indirection, strip dead code
1 parent 784ca14 commit b078dc2

File tree

1 file changed

+7
-24
lines changed

1 file changed

+7
-24
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -176,40 +176,23 @@ inline int_pred_ty<is_zero_int> m_ZeroInt() {
176176
/// For vectors, this includes constants with undefined elements.
177177
inline int_pred_ty<is_one> m_One() { return int_pred_ty<is_one>(); }
178178

179-
struct apint_match {
180-
const APInt *&Res;
179+
struct bind_const_int {
180+
uint64_t &Res;
181181

182-
apint_match(const APInt *&Res) : Res(Res) {}
182+
bind_const_int(uint64_t &Res) : Res(Res) {}
183183

184184
bool match(VPValue *VPV) const {
185185
if (!VPV->isLiveIn())
186186
return false;
187187
Value *V = VPV->getLiveInIRValue();
188188
if (!V)
189189
return false;
190+
assert(!V->getType()->isVectorTy() && "Unexpected vector live-in");
190191
const auto *CI = dyn_cast<ConstantInt>(V);
191-
if (!CI && V->getType()->isVectorTy())
192-
if (const auto *C = dyn_cast<Constant>(V))
193-
CI = dyn_cast_or_null<ConstantInt>(
194-
C->getSplatValue(/*AllowPoison=*/false));
195192
if (!CI)
196193
return false;
197-
Res = &CI->getValue();
198-
return true;
199-
}
200-
};
201-
202-
struct bind_const_intval_ty {
203-
uint64_t &VR;
204-
205-
bind_const_intval_ty(uint64_t &V) : VR(V) {}
206-
207-
template <typename ITy> bool match(ITy *V) const {
208-
const APInt *ConstInt;
209-
if (!apint_match(ConstInt).match(V))
210-
return false;
211-
if (auto C = ConstInt->tryZExtValue()) {
212-
VR = *C;
194+
if (auto C = CI->getValue().tryZExtValue()) {
195+
Res = *C;
213196
return true;
214197
}
215198
return false;
@@ -218,7 +201,7 @@ struct bind_const_intval_ty {
218201

219202
/// Match a plain integer constant no wider than 64-bits, capturing it if we
220203
/// match.
221-
inline bind_const_intval_ty m_ConstantInt(uint64_t &C) { return C; }
204+
inline bind_const_int m_ConstantInt(uint64_t &C) { return C; }
222205

223206
/// Matching combinators
224207
template <typename LTy, typename RTy> struct match_combine_or {

0 commit comments

Comments
 (0)