@@ -3540,39 +3540,40 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
3540
3540
}
3541
3541
}
3542
3542
3543
- // Basic assume equality optimization: assume(x == c) -> replace dominated uses of x with c
3543
+ // Basic assume equality optimization: assume(x == c) -> replace uses of x
3544
+ // with c
3544
3545
if (auto *ICmp = dyn_cast<ICmpInst>(IIOperand)) {
3545
3546
if (ICmp->getPredicate () == ICmpInst::ICMP_EQ) {
3546
3547
Value *LHS = ICmp->getOperand (0 );
3547
3548
Value *RHS = ICmp->getOperand (1 );
3548
3549
Value *Variable = nullptr ;
3549
3550
Constant *ConstantVal = nullptr ;
3550
-
3551
+
3551
3552
if (auto *C = dyn_cast<Constant>(RHS)) {
3552
3553
Variable = LHS;
3553
3554
ConstantVal = C;
3554
3555
} else if (auto *C = dyn_cast<Constant>(LHS)) {
3555
3556
Variable = RHS;
3556
3557
ConstantVal = C;
3557
3558
}
3558
-
3559
+
3559
3560
if (Variable && ConstantVal && Variable->hasUseList ()) {
3560
- SmallVector<Use *, 8 > DominatedUses ;
3561
+ SmallVector<Use *, 8 > Uses ;
3561
3562
for (Use &U : Variable->uses ()) {
3562
3563
if (auto *UseInst = dyn_cast<Instruction>(U.getUser ())) {
3563
- if (UseInst != II && UseInst != ICmp &&
3564
+ if (UseInst != ICmp &&
3564
3565
isValidAssumeForContext (II, UseInst, &DT)) {
3565
- DominatedUses .push_back (&U);
3566
+ Uses .push_back (&U);
3566
3567
}
3567
3568
}
3568
3569
}
3569
-
3570
- for (Use *U : DominatedUses ) {
3570
+
3571
+ for (Use *U : Uses ) {
3571
3572
U->set (ConstantVal);
3572
3573
Worklist.pushValue (U->getUser ());
3573
3574
}
3574
-
3575
- if (!DominatedUses .empty ()) {
3575
+
3576
+ if (!Uses .empty ()) {
3576
3577
Worklist.pushValue (Variable);
3577
3578
}
3578
3579
}
@@ -3581,31 +3582,32 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
3581
3582
3582
3583
// Optimize AMDGPU ballot patterns in assumes:
3583
3584
// assume(ballot(cmp) == -1) means cmp is true on all active lanes
3584
- // We can replace uses of cmp with true in dominated contexts
3585
+ // We can replace uses of cmp with true
3585
3586
Value *BallotInst;
3586
- if (match (IIOperand, m_SpecificICmp (ICmpInst::ICMP_EQ, m_Value (BallotInst), m_AllOnes ()))) {
3587
+ if (match (IIOperand, m_SpecificICmp (ICmpInst::ICMP_EQ, m_Value (BallotInst),
3588
+ m_AllOnes ()))) {
3587
3589
if (auto *IntrCall = dyn_cast<IntrinsicInst>(BallotInst)) {
3588
3590
if (IntrCall->getIntrinsicID () == Intrinsic::amdgcn_ballot) {
3589
3591
Value *BallotArg = IntrCall->getArgOperand (0 );
3590
3592
if (BallotArg->getType ()->isIntegerTy (1 ) && BallotArg->hasUseList ()) {
3591
- // Find dominated uses and replace with true
3592
- SmallVector<Use *, 8 > DominatedUses ;
3593
+ // Find uses and replace with true
3594
+ SmallVector<Use *, 8 > Uses ;
3593
3595
for (Use &U : BallotArg->uses ()) {
3594
3596
if (auto *UseInst = dyn_cast<Instruction>(U.getUser ())) {
3595
- if (UseInst != II && UseInst != IntrCall &&
3597
+ if (UseInst != IntrCall &&
3596
3598
isValidAssumeForContext (II, UseInst, &DT)) {
3597
- DominatedUses .push_back (&U);
3599
+ Uses .push_back (&U);
3598
3600
}
3599
3601
}
3600
3602
}
3601
-
3602
- // Replace dominated uses with true
3603
- for (Use *U : DominatedUses ) {
3603
+
3604
+ // Replace uses with true
3605
+ for (Use *U : Uses ) {
3604
3606
U->set (ConstantInt::getTrue (BallotArg->getType ()));
3605
3607
Worklist.pushValue (U->getUser ());
3606
3608
}
3607
-
3608
- if (!DominatedUses .empty ()) {
3609
+
3610
+ if (!Uses .empty ()) {
3609
3611
Worklist.pushValue (BallotArg);
3610
3612
}
3611
3613
}
@@ -5079,5 +5081,3 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
5079
5081
Call.setCalledFunction (FTy, NestF);
5080
5082
return &Call;
5081
5083
}
5082
-
5083
-
0 commit comments