[llvm] [AArch64] Extend condition optimizer to support unsigned comparisons (PR #144380)

via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 3 05:46:52 PST 2026


================
@@ -248,13 +265,23 @@ AArch64ConditionOptimizer::CmpInfo AArch64ConditionOptimizer::adjustCmp(
   const int OldImm = (int)CmpMI->getOperand(2).getImm();
   const int NewImm = std::abs(OldImm + Correction);
 
-  // Handle +0 -> -1 and -0 -> +1 (CMN with 0 immediate) transitions by
-  // adjusting compare instruction opcode.
-  if (OldImm == 0 && ((Negative && Correction == 1) ||
-                      (!Negative && Correction == -1))) {
+  // Handle cmn 1 -> cmp 0, transitions by adjusting compare instruction opcode.
+  if (OldImm == 1 && Negative && Correction == -1) {
----------------
SiliconA-Z wrote:

Also this is an unsigned wrap, the very thing I said we need to be careful about.

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


More information about the llvm-commits mailing list