[llvm] [AArch64] Fold CSET + BR_CC into a conditional branch (PR #207398)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 13 04:36:20 PDT 2026


================
@@ -11725,6 +11725,24 @@ SDValue AArch64TargetLowering::LowerBR_CC(SDValue Op, SelectionDAG &DAG) const {
                        Overflow);
   }
 
+  // Fold CSET + BR_CC to a conditional branch (rather than keeping the CSET
+  // and emitting a TB[N]Z below).
+  {
+    using namespace llvm::SDPatternMatch;
+    SDValue Flags;
+    uint64_t InvCC;
+    auto m_CSET = m_Node(AArch64ISD::CSINC, m_Zero(), m_Zero(),
+                         m_ConstInt(InvCC), m_Value(Flags));
----------------
gbossu wrote:

Nit: It's a bit confusing that the matcher is called `m_CSET` but we are matching `CSINC`. Maybe leave a comment to say that `CSINC 0, 0` is (AFAIK) the standard way to turn flags into a boolean.

https://github.com/llvm/llvm-project/pull/207398


More information about the llvm-commits mailing list