Skip to content

[DAGCombine] Add all users of the instruction recursively into worklist when an instruction is simplified #91772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ namespace {
/// When an instruction is simplified, add all users of the instruction to
/// the work lists because they might get more simplified now.
void AddUsersToWorklist(SDNode *N) {
for (SDNode *Node : N->uses())
for (SDNode *Node : N->uses()) {
AddToWorklist(Node);
AddUsersToWorklist(Node);
}
}

/// Convenient shorthand to add a node and all of its user to the worklist.
Expand Down
29 changes: 8 additions & 21 deletions llvm/test/CodeGen/X86/addcarry.ll
Original file line number Diff line number Diff line change
Expand Up @@ -317,21 +317,13 @@ define %S @readd(ptr nocapture readonly %this, %S %arg.b) nounwind {
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: movq %rdi, %rax
; CHECK-NEXT: addq (%rsi), %rdx
; CHECK-NEXT: movq 8(%rsi), %rdi
; CHECK-NEXT: adcq $0, %rdi
; CHECK-NEXT: setb %r10b
; CHECK-NEXT: movzbl %r10b, %r10d
; CHECK-NEXT: addq %rcx, %rdi
; CHECK-NEXT: adcq 16(%rsi), %r10
; CHECK-NEXT: setb %cl
; CHECK-NEXT: movzbl %cl, %ecx
; CHECK-NEXT: addq %r8, %r10
; CHECK-NEXT: adcq 24(%rsi), %rcx
; CHECK-NEXT: addq %r9, %rcx
; CHECK-NEXT: movq %rdx, (%rax)
; CHECK-NEXT: movq %rdi, 8(%rax)
; CHECK-NEXT: movq %r10, 16(%rax)
; CHECK-NEXT: movq %rcx, 24(%rax)
; CHECK-NEXT: adcq 8(%rsi), %rcx
; CHECK-NEXT: adcq 16(%rsi), %r8
; CHECK-NEXT: adcq 24(%rsi), %r9
; CHECK-NEXT: movq %rdx, (%rdi)
; CHECK-NEXT: movq %rcx, 8(%rdi)
; CHECK-NEXT: movq %r8, 16(%rdi)
; CHECK-NEXT: movq %r9, 24(%rdi)
; CHECK-NEXT: retq
entry:
%0 = extractvalue %S %arg.b, 0
Expand Down Expand Up @@ -422,14 +414,9 @@ define i128 @addcarry_to_subcarry(i64 %a, i64 %b) nounwind {
; CHECK: # %bb.0:
; CHECK-NEXT: movq %rdi, %rax
; CHECK-NEXT: cmpq %rsi, %rdi
; CHECK-NEXT: notq %rsi
; CHECK-NEXT: sbbq %rsi, %rax
; CHECK-NEXT: setae %cl
; CHECK-NEXT: addb $-1, %cl
; CHECK-NEXT: adcq $0, %rax
; CHECK-NEXT: setb %cl
; CHECK-NEXT: movzbl %cl, %edx
; CHECK-NEXT: addq %rsi, %rax
; CHECK-NEXT: adcq $0, %rdx
; CHECK-NEXT: retq
%notb = xor i64 %b, -1
%notb128 = zext i64 %notb to i128
Expand Down
Loading