[llvm] [AArch64] Use CMN instruction for negative SUBS immediates (PR #221398)

Mugundan S via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 19:59:16 PDT 2026


================
@@ -21996,6 +21996,28 @@ static SDValue performANDORCSELCombine(SDNode *N, SelectionDAG &DAG) {
     return SDValue();
 
   SDLoc DL(N);
+  // If the opcode is SUBS and the comparison value is negative, transform
+  // it to ADDS (CMN) when abs(C) - 1 is a legal arithmetic immediate,
+  // avoiding materialization of the constant into a register.
----------------
MGN-GIT wrote:

Hi @efriedma-quic 

This patch is not required, I could see my prefer block already maps correctly to cmn without this opcode custom matching. 

Thanks for the heads up

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


More information about the llvm-commits mailing list