File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
llvm/lib/Transforms/Scalar Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -2540,6 +2540,21 @@ bool GVNPass::propagateEquality(
25402540 }
25412541 }
25422542
2543+ // If "ballot(cond) == -1" or "ballot(cond) == exec_mask" then cond is true
2544+ // on all active lanes, so cond can be replaced with true.
2545+ if (IntrinsicInst *IntrCall = dyn_cast<IntrinsicInst>(LHS)) {
2546+ if (IntrCall->getIntrinsicID () ==
2547+ Intrinsic::AMDGCNIntrinsics::amdgcn_ballot) {
2548+ Value *BallotArg = IntrCall->getArgOperand (0 );
2549+ if (BallotArg->getType ()->isIntegerTy (1 ) &&
2550+ (match (RHS, m_AllOnes ()) || !isa<Constant>(RHS))) {
2551+ Worklist.push_back (std::make_pair (
2552+ BallotArg, ConstantInt::getTrue (BallotArg->getType ())));
2553+ continue ;
2554+ }
2555+ }
2556+ }
2557+
25432558 // Now try to deduce additional equalities from this one. For example, if
25442559 // the known equality was "(A != B)" == "false" then it follows that A and B
25452560 // are equal in the scope. Only boolean equalities with an explicit true or
You can’t perform that action at this time.
0 commit comments