Skip to content
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
13 changes: 13 additions & 0 deletions llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24534,6 +24534,19 @@ static SDValue performBRCONDCombine(SDNode *N,
if (CC != AArch64CC::EQ && CC != AArch64CC::NE)
return SDValue();

// Fold away brcond(NE, cmp(csel(1, 0, CC, Cmp), 1)) -> brcond(~CC, Cmp)
if (isCMP(Cmp) && CC == AArch64CC::NE && isOneConstant(Cmp.getOperand(1))) {
SDValue CSel = Cmp.getOperand(0);
auto CSelCC = getCSETCondCode(CSel);
if (CSelCC) {
SDLoc DL(N);
return DAG.getNode(
N->getOpcode(), DL, N->getVTList(), Chain, Dest,
DAG.getConstant(getInvertedCondCode(*CSelCC), DL, MVT::i32),
CSel.getOperand(3));
}
}

unsigned CmpOpc = Cmp.getOpcode();
if (CmpOpc != AArch64ISD::ADDS && CmpOpc != AArch64ISD::SUBS)
return SDValue();
Expand Down
35 changes: 15 additions & 20 deletions llvm/test/CodeGen/AArch64/Atomics/aarch64-atomicrmw-lsfe.ll
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,10 @@ define dso_local bfloat @atomicrmw_fsub_bfloat_aligned_monotonic(ptr %ptr, bfloa
; -O0-LABEL: atomicrmw_fsub_bfloat_aligned_monotonic:
; -O0: add w8, w8, w9
; -O0: add w8, w8, w9
; -O0: ldaxrh w9, [x11]
; -O0: cmp w9, w8, uxth
; -O0: ldaxrh w8, [x11]
; -O0: cmp w8, w9, uxth
; -O0: stlxrh w10, w12, [x11]
; -O0: subs w8, w9, w8, uxth
; -O0: subs w8, w8, #1
; -O0: subs w9, w8, w9, uxth
;
; -O1-LABEL: atomicrmw_fsub_bfloat_aligned_monotonic:
; -O1: ldxrh w9, [x0]
Expand All @@ -470,11 +469,10 @@ define dso_local bfloat @atomicrmw_fsub_bfloat_aligned_acquire(ptr %ptr, bfloat
; -O0-LABEL: atomicrmw_fsub_bfloat_aligned_acquire:
; -O0: add w8, w8, w9
; -O0: add w8, w8, w9
; -O0: ldaxrh w9, [x11]
; -O0: cmp w9, w8, uxth
; -O0: ldaxrh w8, [x11]
; -O0: cmp w8, w9, uxth
; -O0: stlxrh w10, w12, [x11]
; -O0: subs w8, w9, w8, uxth
; -O0: subs w8, w8, #1
; -O0: subs w9, w8, w9, uxth
;
; -O1-LABEL: atomicrmw_fsub_bfloat_aligned_acquire:
; -O1: ldaxrh w9, [x0]
Expand All @@ -489,11 +487,10 @@ define dso_local bfloat @atomicrmw_fsub_bfloat_aligned_release(ptr %ptr, bfloat
; -O0-LABEL: atomicrmw_fsub_bfloat_aligned_release:
; -O0: add w8, w8, w9
; -O0: add w8, w8, w9
; -O0: ldaxrh w9, [x11]
; -O0: cmp w9, w8, uxth
; -O0: ldaxrh w8, [x11]
; -O0: cmp w8, w9, uxth
; -O0: stlxrh w10, w12, [x11]
; -O0: subs w8, w9, w8, uxth
; -O0: subs w8, w8, #1
; -O0: subs w9, w8, w9, uxth
;
; -O1-LABEL: atomicrmw_fsub_bfloat_aligned_release:
; -O1: ldxrh w9, [x0]
Expand All @@ -508,11 +505,10 @@ define dso_local bfloat @atomicrmw_fsub_bfloat_aligned_acq_rel(ptr %ptr, bfloat
; -O0-LABEL: atomicrmw_fsub_bfloat_aligned_acq_rel:
; -O0: add w8, w8, w9
; -O0: add w8, w8, w9
; -O0: ldaxrh w9, [x11]
; -O0: cmp w9, w8, uxth
; -O0: ldaxrh w8, [x11]
; -O0: cmp w8, w9, uxth
; -O0: stlxrh w10, w12, [x11]
; -O0: subs w8, w9, w8, uxth
; -O0: subs w8, w8, #1
; -O0: subs w9, w8, w9, uxth
;
; -O1-LABEL: atomicrmw_fsub_bfloat_aligned_acq_rel:
; -O1: ldaxrh w9, [x0]
Expand All @@ -527,11 +523,10 @@ define dso_local bfloat @atomicrmw_fsub_bfloat_aligned_seq_cst(ptr %ptr, bfloat
; -O0-LABEL: atomicrmw_fsub_bfloat_aligned_seq_cst:
; -O0: add w8, w8, w9
; -O0: add w8, w8, w9
; -O0: ldaxrh w9, [x11]
; -O0: cmp w9, w8, uxth
; -O0: ldaxrh w8, [x11]
; -O0: cmp w8, w9, uxth
; -O0: stlxrh w10, w12, [x11]
; -O0: subs w8, w9, w8, uxth
; -O0: subs w8, w8, #1
; -O0: subs w9, w8, w9, uxth
;
; -O1-LABEL: atomicrmw_fsub_bfloat_aligned_seq_cst:
; -O1: ldaxrh w9, [x0]
Expand Down
Loading
Loading