[llvm] [AArch64] Fold a branch on a CSEL of 0 and 1 into a branch on the flags (PR #221456)
David Tellenbach via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 6 11:24:53 PDT 2026
================
@@ -12189,9 +12189,14 @@ SDValue AArch64TargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
// `CSET <Wd>, <cond>` is an alias of `CSINC <Wd>, WZR, WZR, invert(<cond>)`
auto m_CSET = m_Node(AArch64ISD::CSINC, m_Zero(), m_Zero(),
m_ConstInt(InverseCC), m_Value(Flags));
+ // `CSEL <Wd>, 0, 1, <cond>` computes the same value as that CSINC; it is
----------------
dtellenbach wrote:
The trick here is that in SDAG, the CSEL node doesn't only compute the same value but IS a CINC for these immediates: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/AArch64/AArch64InstrInfo.td#L3610-L3613
https://github.com/llvm/llvm-project/pull/221456
More information about the llvm-commits
mailing list