Skip to content

Commit 503dd24

Browse files
committed
Fix pattern matching for comparison with BTC
Following Commit 870f753 a broadcast is materialized for the BTC, so update our pattern-matching logic to look for a comparison with a broadcast of the BTC rather than the BTC itself.
1 parent e0cfe7c commit 503dd24

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

llvm/lib/Transforms/Vectorize/VPlanPatternMatch.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,12 @@ m_BranchOnCond(const Op0_t &Op0) {
246246
return m_VPInstruction<VPInstruction::BranchOnCond>(Op0);
247247
}
248248

249+
template <typename Op0_t>
250+
inline UnaryVPInstruction_match<Op0_t, VPInstruction::Broadcast>
251+
m_Broadcast(const Op0_t &Op0) {
252+
return m_VPInstruction<VPInstruction::Broadcast>(Op0);
253+
}
254+
249255
template <typename Op0_t, typename Op1_t>
250256
inline BinaryVPInstruction_match<Op0_t, Op1_t, VPInstruction::ActiveLaneMask>
251257
m_ActiveLaneMask(const Op0_t &Op0, const Op1_t &Op1) {

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,10 +1136,11 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
11361136
// Currently only handle cases where the single user is a header-mask
11371137
// comparison with the backedge-taken-count.
11381138
using namespace VPlanPatternMatch;
1139-
if (!match(*WideIV->user_begin(),
1140-
m_Binary<Instruction::ICmp>(
1141-
m_Specific(WideIV),
1142-
m_Specific(Plan.getOrCreateBackedgeTakenCount()))))
1139+
if (!match(
1140+
*WideIV->user_begin(),
1141+
m_Binary<Instruction::ICmp>(
1142+
m_Specific(WideIV),
1143+
m_Broadcast(m_Specific(Plan.getOrCreateBackedgeTakenCount())))))
11431144
continue;
11441145

11451146
// Update IV operands and comparison bound to use new narrower type.

0 commit comments

Comments
 (0)