[llvm] [AArch64][GISel] Use emitIntegerCompare instead of emitting SUBS directly every time (PR #153659)

via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 14 12:48:59 PDT 2025


https://github.com/AZero13 created https://github.com/llvm/llvm-project/pull/153659

Also, pass the same operands to it as we do in SelDAG, same with emitFPCompare.

>From 11fe8ec4483127b1b8b639beb332266ec3bcfb44 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Thu, 14 Aug 2025 15:43:57 -0400
Subject: [PATCH] [AArch64] Use emitIntegerCompare instead of emitting SUBS
 directly every time

Also, pass the same operands to it as we do in SelDAG, same with emitFPCompare.
---
 .../lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index ee34a85a5b507..691fabbd1ac67 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -4965,11 +4965,9 @@ MachineInstr *AArch64InstructionSelector::emitConjunctionRec(
 
     // Produce a normal comparison if we are first in the chain
     if (!CCOp) {
-      auto Dst = MRI.cloneVirtualRegister(LHS);
       if (isa<GICmp>(Cmp))
-        return emitSUBS(Dst, Cmp->getOperand(2), Cmp->getOperand(3), MIB);
-      return emitFPCompare(Cmp->getOperand(2).getReg(),
-                           Cmp->getOperand(3).getReg(), MIB);
+        return emitIntegerCompare(LHS, RHS, CC, MIB);
+      return emitFPCompare(LHS, RHS, MIB, CC);
     }
     // Otherwise produce a ccmp.
     return emitConditionalComparison(LHS, RHS, CC, Predicate, OutCC, MIB);



More information about the llvm-commits mailing list