Skip to content

Commit f00dfa2

Browse files
Address @ssahasra's review feedback
- Remove 'dominated' terminology from comments and variable names (SSA values always dominate their uses) - Rename DominatedUses -> Uses throughout - Remove redundant UseInst != II check in ICmp block - Fix code formatting (clang-format) - Split long comment lines - Remove extra blank lines at EOF
1 parent c577951 commit f00dfa2

File tree

2 files changed

+25
-25
lines changed

2 files changed

+25
-25
lines changed

llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3540,39 +3540,40 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
35403540
}
35413541
}
35423542

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
35443545
if (auto *ICmp = dyn_cast<ICmpInst>(IIOperand)) {
35453546
if (ICmp->getPredicate() == ICmpInst::ICMP_EQ) {
35463547
Value *LHS = ICmp->getOperand(0);
35473548
Value *RHS = ICmp->getOperand(1);
35483549
Value *Variable = nullptr;
35493550
Constant *ConstantVal = nullptr;
3550-
3551+
35513552
if (auto *C = dyn_cast<Constant>(RHS)) {
35523553
Variable = LHS;
35533554
ConstantVal = C;
35543555
} else if (auto *C = dyn_cast<Constant>(LHS)) {
35553556
Variable = RHS;
35563557
ConstantVal = C;
35573558
}
3558-
3559+
35593560
if (Variable && ConstantVal && Variable->hasUseList()) {
3560-
SmallVector<Use *, 8> DominatedUses;
3561+
SmallVector<Use *, 8> Uses;
35613562
for (Use &U : Variable->uses()) {
35623563
if (auto *UseInst = dyn_cast<Instruction>(U.getUser())) {
3563-
if (UseInst != II && UseInst != ICmp &&
3564+
if (UseInst != ICmp &&
35643565
isValidAssumeForContext(II, UseInst, &DT)) {
3565-
DominatedUses.push_back(&U);
3566+
Uses.push_back(&U);
35663567
}
35673568
}
35683569
}
3569-
3570-
for (Use *U : DominatedUses) {
3570+
3571+
for (Use *U : Uses) {
35713572
U->set(ConstantVal);
35723573
Worklist.pushValue(U->getUser());
35733574
}
3574-
3575-
if (!DominatedUses.empty()) {
3575+
3576+
if (!Uses.empty()) {
35763577
Worklist.pushValue(Variable);
35773578
}
35783579
}
@@ -3581,31 +3582,32 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
35813582

35823583
// Optimize AMDGPU ballot patterns in assumes:
35833584
// 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
35853586
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()))) {
35873589
if (auto *IntrCall = dyn_cast<IntrinsicInst>(BallotInst)) {
35883590
if (IntrCall->getIntrinsicID() == Intrinsic::amdgcn_ballot) {
35893591
Value *BallotArg = IntrCall->getArgOperand(0);
35903592
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;
35933595
for (Use &U : BallotArg->uses()) {
35943596
if (auto *UseInst = dyn_cast<Instruction>(U.getUser())) {
3595-
if (UseInst != II && UseInst != IntrCall &&
3597+
if (UseInst != IntrCall &&
35963598
isValidAssumeForContext(II, UseInst, &DT)) {
3597-
DominatedUses.push_back(&U);
3599+
Uses.push_back(&U);
35983600
}
35993601
}
36003602
}
3601-
3602-
// Replace dominated uses with true
3603-
for (Use *U : DominatedUses) {
3603+
3604+
// Replace uses with true
3605+
for (Use *U : Uses) {
36043606
U->set(ConstantInt::getTrue(BallotArg->getType()));
36053607
Worklist.pushValue(U->getUser());
36063608
}
3607-
3608-
if (!DominatedUses.empty()) {
3609+
3610+
if (!Uses.empty()) {
36093611
Worklist.pushValue(BallotArg);
36103612
}
36113613
}
@@ -5079,5 +5081,3 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
50795081
Call.setCalledFunction(FTy, NestF);
50805082
return &Call;
50815083
}
5082-
5083-

llvm/test/Transforms/InstCombine/assume.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,9 +1034,9 @@ define i1 @neg_assume_trunc_eq_one(i8 %x) {
10341034
ret i1 %q
10351035
}
10361036

1037-
; Test AMDGPU ballot pattern optimization
1037+
; Test AMDGPU ballot pattern optimization
10381038
; assume(ballot(cmp) == -1) means cmp is true on all active lanes
1039-
; so dominated uses of cmp can be replaced with true
1039+
; so uses of cmp can be replaced with true
10401040
define void @assume_ballot_uniform(i32 %x) {
10411041
; CHECK-LABEL: @assume_ballot_uniform(
10421042
; CHECK-NEXT: [[CMP:%.*]] = icmp eq i32 [[X:%.*]], 0

0 commit comments

Comments
 (0)