Skip to content

Commit 9906489

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 886412c commit 9906489

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
@@ -1059,10 +1059,11 @@ static bool optimizeVectorInductionWidthForTCAndVFUF(VPlan &Plan,
10591059
// Currently only handle cases where the single user is a header-mask
10601060
// comparison with the backedge-taken-count.
10611061
using namespace VPlanPatternMatch;
1062-
if (!match(*WideIV->user_begin(),
1063-
m_Binary<Instruction::ICmp>(
1064-
m_Specific(WideIV),
1065-
m_Specific(Plan.getOrCreateBackedgeTakenCount()))))
1062+
if (!match(
1063+
*WideIV->user_begin(),
1064+
m_Binary<Instruction::ICmp>(
1065+
m_Specific(WideIV),
1066+
m_Broadcast(m_Specific(Plan.getOrCreateBackedgeTakenCount())))))
10661067
continue;
10671068

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

0 commit comments

Comments
 (0)