Skip to content

Commit a768d65

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 d756218 commit a768d65

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
@@ -3549,39 +3549,40 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
35493549
}
35503550
}
35513551

3552-
// Basic assume equality optimization: assume(x == c) -> replace dominated uses of x with c
3552+
// Basic assume equality optimization: assume(x == c) -> replace uses of x
3553+
// with c
35533554
if (auto *ICmp = dyn_cast<ICmpInst>(IIOperand)) {
35543555
if (ICmp->getPredicate() == ICmpInst::ICMP_EQ) {
35553556
Value *LHS = ICmp->getOperand(0);
35563557
Value *RHS = ICmp->getOperand(1);
35573558
Value *Variable = nullptr;
35583559
Constant *ConstantVal = nullptr;
3559-
3560+
35603561
if (auto *C = dyn_cast<Constant>(RHS)) {
35613562
Variable = LHS;
35623563
ConstantVal = C;
35633564
} else if (auto *C = dyn_cast<Constant>(LHS)) {
35643565
Variable = RHS;
35653566
ConstantVal = C;
35663567
}
3567-
3568+
35683569
if (Variable && ConstantVal && Variable->hasUseList()) {
3569-
SmallVector<Use *, 8> DominatedUses;
3570+
SmallVector<Use *, 8> Uses;
35703571
for (Use &U : Variable->uses()) {
35713572
if (auto *UseInst = dyn_cast<Instruction>(U.getUser())) {
3572-
if (UseInst != II && UseInst != ICmp &&
3573+
if (UseInst != ICmp &&
35733574
isValidAssumeForContext(II, UseInst, &DT)) {
3574-
DominatedUses.push_back(&U);
3575+
Uses.push_back(&U);
35753576
}
35763577
}
35773578
}
3578-
3579-
for (Use *U : DominatedUses) {
3579+
3580+
for (Use *U : Uses) {
35803581
U->set(ConstantVal);
35813582
Worklist.pushValue(U->getUser());
35823583
}
3583-
3584-
if (!DominatedUses.empty()) {
3584+
3585+
if (!Uses.empty()) {
35853586
Worklist.pushValue(Variable);
35863587
}
35873588
}
@@ -3590,31 +3591,32 @@ Instruction *InstCombinerImpl::visitCallInst(CallInst &CI) {
35903591

35913592
// Optimize AMDGPU ballot patterns in assumes:
35923593
// assume(ballot(cmp) == -1) means cmp is true on all active lanes
3593-
// We can replace uses of cmp with true in dominated contexts
3594+
// We can replace uses of cmp with true
35943595
Value *BallotInst;
3595-
if (match(IIOperand, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Value(BallotInst), m_AllOnes()))) {
3596+
if (match(IIOperand, m_SpecificICmp(ICmpInst::ICMP_EQ, m_Value(BallotInst),
3597+
m_AllOnes()))) {
35963598
if (auto *IntrCall = dyn_cast<IntrinsicInst>(BallotInst)) {
35973599
if (IntrCall->getIntrinsicID() == Intrinsic::amdgcn_ballot) {
35983600
Value *BallotArg = IntrCall->getArgOperand(0);
35993601
if (BallotArg->getType()->isIntegerTy(1) && BallotArg->hasUseList()) {
3600-
// Find dominated uses and replace with true
3601-
SmallVector<Use *, 8> DominatedUses;
3602+
// Find uses and replace with true
3603+
SmallVector<Use *, 8> Uses;
36023604
for (Use &U : BallotArg->uses()) {
36033605
if (auto *UseInst = dyn_cast<Instruction>(U.getUser())) {
3604-
if (UseInst != II && UseInst != IntrCall &&
3606+
if (UseInst != IntrCall &&
36053607
isValidAssumeForContext(II, UseInst, &DT)) {
3606-
DominatedUses.push_back(&U);
3608+
Uses.push_back(&U);
36073609
}
36083610
}
36093611
}
3610-
3611-
// Replace dominated uses with true
3612-
for (Use *U : DominatedUses) {
3612+
3613+
// Replace uses with true
3614+
for (Use *U : Uses) {
36133615
U->set(ConstantInt::getTrue(BallotArg->getType()));
36143616
Worklist.pushValue(U->getUser());
36153617
}
3616-
3617-
if (!DominatedUses.empty()) {
3618+
3619+
if (!Uses.empty()) {
36183620
Worklist.pushValue(BallotArg);
36193621
}
36203622
}
@@ -5099,5 +5101,3 @@ InstCombinerImpl::transformCallThroughTrampoline(CallBase &Call,
50995101
Call.setCalledFunction(FTy, NestF);
51005102
return &Call;
51015103
}
5102-
5103-

llvm/test/Transforms/InstCombine/assume.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,9 +1056,9 @@ define i1 @neg_assume_trunc_eq_one(i8 %x) {
10561056
ret i1 %q
10571057
}
10581058

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

0 commit comments

Comments
 (0)