Skip to content

Commit 80068a0

Browse files
lfilipkoigcbot
authored andcommitted
Update discard mask pattern match fix
Update discard mask pattern match fix. Corrected predicate mode is set for discard branch.
1 parent d56e799 commit 80068a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

IGC/Compiler/CISACodeGen/PatternMatchPass.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,6 +3536,7 @@ bool CodeGenPatternMatch::MatchCanonicalizeInstruction(llvm::Instruction &I) {
35363536
}
35373537

35383538
bool CodeGenPatternMatch::MatchBranch(llvm::BranchInst &I) {
3539+
using namespace llvm::PatternMatch;
35393540
struct CondBrInstPattern : Pattern {
35403541
SSource cond;
35413542
llvm::BranchInst *inst;
@@ -3553,9 +3554,24 @@ bool CodeGenPatternMatch::MatchBranch(llvm::BranchInst &I) {
35533554
pattern->inst = &I;
35543555

35553556
if (!I.isUnconditional()) {
3557+
Value *orSrc0 = nullptr;
3558+
Value *orSrc1 = nullptr;
35563559
Value *cond = I.getCondition();
35573560
if (dyn_cast<GenIntrinsicInst>(cond, GenISAIntrinsic::GenISA_UpdateDiscardMask)) {
35583561
pattern->isDiscardBranch = true;
3562+
} else if (match(cond, m_Or(m_Value(orSrc0), m_Value(orSrc1)))) {
3563+
// %6 = call i1 @llvm.genx.GenISA.UpdateDiscardMask(i1 %0, i1 %2)
3564+
// %7 = or i1 %6, %2 (or: %7 = or i1 %2, %6)
3565+
// br i1 %7, label %DiscardRet, label %PostDiscard
3566+
if (auto intr = dyn_cast<GenIntrinsicInst>(orSrc0, GenISAIntrinsic::GenISA_UpdateDiscardMask)) {
3567+
if (intr->getOperand(1) == orSrc1) {
3568+
pattern->isDiscardBranch = true;
3569+
}
3570+
} else if (auto intr = dyn_cast<GenIntrinsicInst>(orSrc1, GenISAIntrinsic::GenISA_UpdateDiscardMask)) {
3571+
if (intr->getOperand(1) == orSrc0) {
3572+
pattern->isDiscardBranch = true;
3573+
}
3574+
}
35593575
}
35603576
pattern->cond = GetSource(I.getCondition(), false, false, IsSourceOfSample(&I));
35613577
}

0 commit comments

Comments
 (0)