Skip to content

[AArch64][SelectionDAG] Mask for SUBS with multiple users cannot be elided #90911

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

Merged
merged 1 commit into from
May 5, 2024
Merged
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
3 changes: 2 additions & 1 deletion llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22833,7 +22833,8 @@ SDValue performCONDCombine(SDNode *N,
SDNode *SubsNode = N->getOperand(CmpIndex).getNode();
unsigned CondOpcode = SubsNode->getOpcode();

if (CondOpcode != AArch64ISD::SUBS || SubsNode->hasAnyUseOfValue(0))
if (CondOpcode != AArch64ISD::SUBS || SubsNode->hasAnyUseOfValue(0) ||
!SubsNode->hasOneUse())
return SDValue();

// There is a SUBS feeding this condition. Is it fed by a mask we can
Expand Down
22 changes: 22 additions & 0 deletions llvm/test/CodeGen/AArch64/and-mask-removal.ll
Original file line number Diff line number Diff line change
Expand Up @@ -526,4 +526,26 @@ define i64 @pr58109b(i8 signext %0, i64 %a, i64 %b) {
ret i64 %4
}

define i64 @test_2_selects(i8 zeroext %a) {
; CHECK-LABEL: test_2_selects:
; CHECK: ; %bb.0:
; CHECK-NEXT: add w9, w0, #24
; CHECK-NEXT: mov w8, #131
; CHECK-NEXT: and w9, w9, #0xff
; CHECK-NEXT: cmp w9, #81
; CHECK-NEXT: mov w9, #57
; CHECK-NEXT: csel x8, x8, xzr, lo
; CHECK-NEXT: csel x9, xzr, x9, eq
; CHECK-NEXT: add x0, x8, x9
; CHECK-NEXT: ret
%1 = add i8 %a, 24
%2 = zext i8 %1 to i64
%3 = icmp ult i8 %1, 81
%4 = select i1 %3, i64 131, i64 0
%5 = icmp eq i8 %1, 81
%6 = select i1 %5, i64 0, i64 57
%7 = add i64 %4, %6
ret i64 %7
}

declare i8 @llvm.usub.sat.i8(i8, i8) #0
Loading