[llvm] [AArch64][GISel] Signed comparison using CMN is safe when the subtraction is nsw (PR #150480)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 28 08:16:31 PDT 2025


https://github.com/AZero13 updated https://github.com/llvm/llvm-project/pull/150480

>From e89d485696b26e6917f4e4d4f10583a228dddac7 Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Thu, 24 Jul 2025 13:24:17 -0400
Subject: [PATCH 1/4] Pre-commit test (NFC)

---
 llvm/test/CodeGen/AArch64/cmp-to-cmn.ll | 453 +++++++++++++++++-------
 1 file changed, 322 insertions(+), 131 deletions(-)

diff --git a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
index 5765e0acae269..d949e10edce45 100644
--- a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
+++ b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
@@ -1,14 +1,21 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
-; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,SDISEL
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s -global-isel | FileCheck %s --check-prefixes=CHECK,GISEL
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "arm64"
 
 define i1 @test_EQ_IllEbT(i64 %a, i64 %b) {
-; CHECK-LABEL: test_EQ_IllEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x0, x1
-; CHECK-NEXT:    cset w0, eq
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_EQ_IllEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x0, x1
+; SDISEL-NEXT:    cset w0, eq
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_EQ_IllEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    cmn x1, x0
+; GISEL-NEXT:    cset w0, eq
+; GISEL-NEXT:    ret
 entry:
   %add = sub i64 0, %b
   %cmp = icmp eq i64 %add, %a
@@ -16,11 +23,19 @@ entry:
 }
 
 define i1 @test_EQ_IliEbT(i64 %a, i32 %b) {
-; CHECK-LABEL: test_EQ_IliEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x0, w1, sxtw
-; CHECK-NEXT:    cset w0, eq
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_EQ_IliEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x0, w1, sxtw
+; SDISEL-NEXT:    cset w0, eq
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_EQ_IliEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    // kill: def $w1 killed $w1 def $x1
+; GISEL-NEXT:    sxtw x8, w1
+; GISEL-NEXT:    cmn x8, x0
+; GISEL-NEXT:    cset w0, eq
+; GISEL-NEXT:    ret
 entry:
   %conv = sext i32 %b to i64
   %add = sub i64 0, %a
@@ -55,11 +70,19 @@ entry:
 }
 
 define i1 @test_EQ_IilEbT(i32 %a, i64 %b) {
-; CHECK-LABEL: test_EQ_IilEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x1, w0, sxtw
-; CHECK-NEXT:    cset w0, eq
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_EQ_IilEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x1, w0, sxtw
+; SDISEL-NEXT:    cset w0, eq
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_EQ_IilEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    // kill: def $w0 killed $w0 def $x0
+; GISEL-NEXT:    sxtw x8, w0
+; GISEL-NEXT:    cmn x8, x1
+; GISEL-NEXT:    cset w0, eq
+; GISEL-NEXT:    ret
 entry:
   %conv = sext i32 %a to i64
   %add = sub i64 0, %b
@@ -68,11 +91,17 @@ entry:
 }
 
 define i1 @test_EQ_IiiEbT(i32 %a, i32 %b) {
-; CHECK-LABEL: test_EQ_IiiEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn w0, w1
-; CHECK-NEXT:    cset w0, eq
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_EQ_IiiEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn w0, w1
+; SDISEL-NEXT:    cset w0, eq
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_EQ_IiiEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    cmn w1, w0
+; GISEL-NEXT:    cset w0, eq
+; GISEL-NEXT:    ret
 entry:
   %add = sub i32 0, %b
   %cmp = icmp eq i32 %add, %a
@@ -218,11 +247,17 @@ entry:
 }
 
 define i1 @test_NE_IllEbT(i64 %a, i64 %b) {
-; CHECK-LABEL: test_NE_IllEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x0, x1
-; CHECK-NEXT:    cset w0, ne
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_NE_IllEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x0, x1
+; SDISEL-NEXT:    cset w0, ne
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_NE_IllEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    cmn x1, x0
+; GISEL-NEXT:    cset w0, ne
+; GISEL-NEXT:    ret
 entry:
   %add = sub i64 0, %b
   %cmp = icmp ne i64 %add, %a
@@ -230,11 +265,19 @@ entry:
 }
 
 define i1 @test_NE_IliEbT(i64 %a, i32 %b) {
-; CHECK-LABEL: test_NE_IliEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x0, w1, sxtw
-; CHECK-NEXT:    cset w0, ne
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_NE_IliEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x0, w1, sxtw
+; SDISEL-NEXT:    cset w0, ne
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_NE_IliEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    // kill: def $w1 killed $w1 def $x1
+; GISEL-NEXT:    sxtw x8, w1
+; GISEL-NEXT:    cmn x8, x0
+; GISEL-NEXT:    cset w0, ne
+; GISEL-NEXT:    ret
 entry:
   %conv = sext i32 %b to i64
   %add = sub i64 0, %a
@@ -269,11 +312,19 @@ entry:
 }
 
 define i1 @test_NE_IilEbT(i32 %a, i64 %b) {
-; CHECK-LABEL: test_NE_IilEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn x1, w0, sxtw
-; CHECK-NEXT:    cset w0, ne
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_NE_IilEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn x1, w0, sxtw
+; SDISEL-NEXT:    cset w0, ne
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_NE_IilEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    // kill: def $w0 killed $w0 def $x0
+; GISEL-NEXT:    sxtw x8, w0
+; GISEL-NEXT:    cmn x8, x1
+; GISEL-NEXT:    cset w0, ne
+; GISEL-NEXT:    ret
 entry:
   %conv = sext i32 %a to i64
   %add = sub i64 0, %b
@@ -282,11 +333,17 @@ entry:
 }
 
 define i1 @test_NE_IiiEbT(i32 %a, i32 %b) {
-; CHECK-LABEL: test_NE_IiiEbT:
-; CHECK:       // %bb.0: // %entry
-; CHECK-NEXT:    cmn w0, w1
-; CHECK-NEXT:    cset w0, ne
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: test_NE_IiiEbT:
+; SDISEL:       // %bb.0: // %entry
+; SDISEL-NEXT:    cmn w0, w1
+; SDISEL-NEXT:    cset w0, ne
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: test_NE_IiiEbT:
+; GISEL:       // %bb.0: // %entry
+; GISEL-NEXT:    cmn w1, w0
+; GISEL-NEXT:    cset w0, ne
+; GISEL-NEXT:    ret
 entry:
   %add = sub i32 0, %b
   %cmp = icmp ne i32 %add, %a
@@ -444,182 +501,316 @@ define i1 @cmn_large_imm(i32 %a) {
 }
 
 define i1 @almost_immediate_neg_slt(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_slt:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, le
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_slt:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, le
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_slt:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #4097 // =0x1001
+; GISEL-NEXT:    movk w8, #65281, lsl #16
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, lt
+; GISEL-NEXT:    ret
   %cmp = icmp slt i32 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_slt_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_slt_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, le
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_slt_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, le
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_slt_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GISEL-NEXT:    movk x8, #65281, lsl #16
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, lt
+; GISEL-NEXT:    ret
   %cmp = icmp slt i64 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sge(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_sge:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, gt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sge:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, gt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sge:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #4097 // =0x1001
+; GISEL-NEXT:    movk w8, #65281, lsl #16
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, ge
+; GISEL-NEXT:    ret
   %cmp = icmp sge i32 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sge_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_sge_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, gt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sge_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, gt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sge_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GISEL-NEXT:    movk x8, #65281, lsl #16
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, ge
+; GISEL-NEXT:    ret
   %cmp = icmp sge i64 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_uge(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_uge:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, hi
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_uge:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, hi
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_uge:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #4097 // =0x1001
+; GISEL-NEXT:    movk w8, #65281, lsl #16
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, hs
+; GISEL-NEXT:    ret
   %cmp = icmp uge i32 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_uge_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_uge_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, hi
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_uge_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, hi
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_uge_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GISEL-NEXT:    movk x8, #65281, lsl #16
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, hs
+; GISEL-NEXT:    ret
   %cmp = icmp uge i64 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ult(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_ult:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, ls
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ult:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, ls
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ult:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #4097 // =0x1001
+; GISEL-NEXT:    movk w8, #65281, lsl #16
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, lo
+; GISEL-NEXT:    ret
   %cmp = icmp ult i32 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ult_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_ult_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; CHECK-NEXT:    cset w0, ls
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ult_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SDISEL-NEXT:    cset w0, ls
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ult_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GISEL-NEXT:    movk x8, #65281, lsl #16
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, lo
+; GISEL-NEXT:    ret
   %cmp = icmp ult i64 %x, -16707583
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sle(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_sle:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, lt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sle:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, lt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sle:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, le
+; GISEL-NEXT:    ret
   %cmp = icmp sle i32 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sle_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_sle_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, lt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sle_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, lt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sle_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, le
+; GISEL-NEXT:    ret
   %cmp = icmp sle i64 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sgt(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_sgt:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, ge
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sgt:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, ge
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sgt:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, gt
+; GISEL-NEXT:    ret
   %cmp = icmp sgt i32 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_sgt_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_sgt_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, ge
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_sgt_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, ge
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_sgt_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, gt
+; GISEL-NEXT:    ret
   %cmp = icmp sgt i64 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ule(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_ule:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, lo
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ule:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, lo
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ule:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, ls
+; GISEL-NEXT:    ret
   %cmp = icmp ule i32 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ule_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_ule_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, lo
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ule_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, lo
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ule_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, ls
+; GISEL-NEXT:    ret
   %cmp = icmp ule i64 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ugt(i32 %x) {
-; CHECK-LABEL: almost_immediate_neg_ugt:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, hs
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ugt:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, hs
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ugt:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, hi
+; GISEL-NEXT:    ret
   %cmp = icmp ugt i32 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @almost_immediate_neg_ugt_64(i64 %x) {
-; CHECK-LABEL: almost_immediate_neg_ugt_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; CHECK-NEXT:    cset w0, hs
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: almost_immediate_neg_ugt_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SDISEL-NEXT:    cset w0, hs
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: almost_immediate_neg_ugt_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, hi
+; GISEL-NEXT:    ret
   %cmp = icmp ugt i64 %x, -16773121
   ret i1 %cmp
 }
 
 define i1 @cmn_nsw(i32 %a, i32 %b) {
-; CHECK-LABEL: cmn_nsw:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn w0, w1
-; CHECK-NEXT:    cset w0, gt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: cmn_nsw:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, w1
+; SDISEL-NEXT:    cset w0, gt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: cmn_nsw:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    neg w8, w1
+; GISEL-NEXT:    cmp w0, w8
+; GISEL-NEXT:    cset w0, gt
+; GISEL-NEXT:    ret
   %sub = sub nsw i32 0, %b
   %cmp = icmp sgt i32 %a, %sub
   ret i1 %cmp
 }
 
 define i1 @cmn_nsw_64(i64 %a, i64 %b) {
-; CHECK-LABEL: cmn_nsw_64:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    cmn x0, x1
-; CHECK-NEXT:    cset w0, gt
-; CHECK-NEXT:    ret
+; SDISEL-LABEL: cmn_nsw_64:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn x0, x1
+; SDISEL-NEXT:    cset w0, gt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: cmn_nsw_64:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    neg x8, x1
+; GISEL-NEXT:    cmp x0, x8
+; GISEL-NEXT:    cset w0, gt
+; GISEL-NEXT:    ret
   %sub = sub nsw i64 0, %b
   %cmp = icmp sgt i64 %a, %sub
   ret i1 %cmp

>From d2e62bd81de9c3725f840790174d5f98efb4b16e Mon Sep 17 00:00:00 2001
From: Rose <gfunni234 at gmail.com>
Date: Thu, 24 Jul 2025 13:25:42 -0400
Subject: [PATCH 2/4] [AArch64][GISel] Signed comparison using CMN is safe when
 the subtraction is nsw

https://github.com/llvm/llvm-project/pull/141993 but for GISel, though for LHS, we now do the inverse compare, something that SelDAG does not do as of now but I will do in a future patch.
---
 .../AArch64/GISel/AArch64GlobalISelUtils.cpp  |  4 +-
 .../GISel/AArch64InstructionSelector.cpp      | 47 ++++++++++-------
 ...galizer-lowering-swap-compare-operands.mir |  5 +-
 llvm/test/CodeGen/AArch64/cmp-to-cmn.ll       | 52 ++++++++++---------
 4 files changed, 61 insertions(+), 47 deletions(-)

diff --git a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
index 0b798509c26da..1a1507512c899 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64GlobalISelUtils.cpp
@@ -50,8 +50,10 @@ bool AArch64GISelUtils::isCMN(const MachineInstr *MaybeSub,
   //
   // %sub = G_SUB 0, %y
   // %cmp = G_ICMP eq/ne, %z, %sub
+  // or with signed comparisons with the no-signed-wrap flag set
   if (!MaybeSub || MaybeSub->getOpcode() != TargetOpcode::G_SUB ||
-      !CmpInst::isEquality(Pred))
+      (!CmpInst::isEquality(Pred) &&
+       !(CmpInst::isSigned(Pred) && MaybeSub->getFlag(MachineInstr::NoSWrap))))
     return false;
   auto MaybeZero =
       getIConstantVRegValWithLookThrough(MaybeSub->getOperand(1).getReg(), MRI);
diff --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 1381a9b70df87..d9056926ff249 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -1810,7 +1810,7 @@ bool AArch64InstructionSelector::selectCompareBranchFedByICmp(
 
   // Couldn't optimize. Emit a compare + a Bcc.
   MachineBasicBlock *DestMBB = I.getOperand(1).getMBB();
-  auto PredOp = ICmp.getOperand(1);
+  auto &PredOp = ICmp.getOperand(1);
   emitIntegerCompare(ICmp.getOperand(2), ICmp.getOperand(3), PredOp, MIB);
   const AArch64CC::CondCode CC = changeICMPPredToAArch64CC(
       static_cast<CmpInst::Predicate>(PredOp.getPredicate()));
@@ -2506,12 +2506,12 @@ bool AArch64InstructionSelector::earlySelect(MachineInstr &I) {
         return false;
     }
     auto &PredOp = Cmp->getOperand(1);
-    auto Pred = static_cast<CmpInst::Predicate>(PredOp.getPredicate());
-    const AArch64CC::CondCode InvCC =
-        changeICMPPredToAArch64CC(CmpInst::getInversePredicate(Pred));
     MIB.setInstrAndDebugLoc(I);
     emitIntegerCompare(/*LHS=*/Cmp->getOperand(2),
                        /*RHS=*/Cmp->getOperand(3), PredOp, MIB);
+    auto Pred = static_cast<CmpInst::Predicate>(PredOp.getPredicate());
+    const AArch64CC::CondCode InvCC =
+        changeICMPPredToAArch64CC(CmpInst::getInversePredicate(Pred));
     emitCSINC(/*Dst=*/AddDst, /*Src =*/AddLHS, /*Src2=*/AddLHS, InvCC, MIB);
     I.eraseFromParent();
     return true;
@@ -3574,10 +3574,11 @@ bool AArch64InstructionSelector::select(MachineInstr &I) {
       return false;
     }
 
-    auto Pred = static_cast<CmpInst::Predicate>(I.getOperand(1).getPredicate());
+    auto &PredOp = I.getOperand(1);
+    emitIntegerCompare(I.getOperand(2), I.getOperand(3), PredOp, MIB);
+    auto Pred = static_cast<CmpInst::Predicate>(PredOp.getPredicate());
     const AArch64CC::CondCode InvCC =
         changeICMPPredToAArch64CC(CmpInst::getInversePredicate(Pred));
-    emitIntegerCompare(I.getOperand(2), I.getOperand(3), I.getOperand(1), MIB);
     emitCSINC(/*Dst=*/I.getOperand(0).getReg(), /*Src1=*/AArch64::WZR,
               /*Src2=*/AArch64::WZR, InvCC, MIB);
     I.eraseFromParent();
@@ -5096,11 +5097,11 @@ bool AArch64InstructionSelector::tryOptSelect(GSelect &I) {
 
   AArch64CC::CondCode CondCode;
   if (CondOpc == TargetOpcode::G_ICMP) {
-    auto Pred =
-        static_cast<CmpInst::Predicate>(CondDef->getOperand(1).getPredicate());
+    auto &PredOp = CondDef->getOperand(1);
+    emitIntegerCompare(CondDef->getOperand(2), CondDef->getOperand(3), PredOp,
+                       MIB);
+    auto Pred = static_cast<CmpInst::Predicate>(PredOp.getPredicate());
     CondCode = changeICMPPredToAArch64CC(Pred);
-    emitIntegerCompare(CondDef->getOperand(2), CondDef->getOperand(3),
-                       CondDef->getOperand(1), MIB);
   } else {
     // Get the condition code for the select.
     auto Pred =
@@ -5148,29 +5149,37 @@ MachineInstr *AArch64InstructionSelector::tryFoldIntegerCompare(
   MachineInstr *LHSDef = getDefIgnoringCopies(LHS.getReg(), MRI);
   MachineInstr *RHSDef = getDefIgnoringCopies(RHS.getReg(), MRI);
   auto P = static_cast<CmpInst::Predicate>(Predicate.getPredicate());
+
   // Given this:
   //
   // x = G_SUB 0, y
-  // G_ICMP x, z
+  // G_ICMP z, x
   //
   // Produce this:
   //
-  // cmn y, z
-  if (isCMN(LHSDef, P, MRI))
-    return emitCMN(LHSDef->getOperand(2), RHS, MIRBuilder);
+  // cmn z, y
+  if (isCMN(RHSDef, P, MRI))
+    return emitCMN(LHS, RHSDef->getOperand(2), MIRBuilder);
 
-  // Same idea here, but with the RHS of the compare instead:
+  // Same idea here, but with the LHS of the compare instead:
   //
   // Given this:
   //
   // x = G_SUB 0, y
-  // G_ICMP z, x
+  // G_ICMP x, z
   //
   // Produce this:
   //
-  // cmn z, y
-  if (isCMN(RHSDef, P, MRI))
-    return emitCMN(LHS, RHSDef->getOperand(2), MIRBuilder);
+  // cmn y, z
+  //
+  // But be careful! We need to swap the predicate!
+  if (isCMN(LHSDef, P, MRI)) {
+    if (!CmpInst::isEquality(P)) {
+      P = CmpInst::getSwappedPredicate(P);
+      Predicate = MachineOperand::CreatePredicate(P);
+    }
+    return emitCMN(LHSDef->getOperand(2), RHS, MIRBuilder);
+  }
 
   // Given this:
   //
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-swap-compare-operands.mir b/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-swap-compare-operands.mir
index 09e5a15252f86..a422f60aacc0f 100644
--- a/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-swap-compare-operands.mir
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/postlegalizer-lowering-swap-compare-operands.mir
@@ -667,11 +667,10 @@ body:             |
     ; SELECT-NEXT: {{  $}}
     ; SELECT-NEXT: %zero:gpr64 = COPY $xzr
     ; SELECT-NEXT: %reg0:gpr64 = COPY $x0
-    ; SELECT-NEXT: %shl:gpr64 = UBFMXri %reg0, 1, 0
+    ; SELECT-NEXT: %cmp_lhs:gpr64 = SUBSXrs %zero, %reg0, 63, implicit-def dead $nzcv
     ; SELECT-NEXT: %reg1:gpr64 = COPY $x1
     ; SELECT-NEXT: %sext_in_reg:gpr64 = SBFMXri %reg1, 0, 0
-    ; SELECT-NEXT: %cmp_rhs:gpr64 = SUBSXrs %zero, %sext_in_reg, 131, implicit-def dead $nzcv
-    ; SELECT-NEXT: [[ADDSXrr:%[0-9]+]]:gpr64 = ADDSXrr %shl, %cmp_rhs, implicit-def $nzcv
+    ; SELECT-NEXT: [[ADDSXrs:%[0-9]+]]:gpr64 = ADDSXrs %cmp_lhs, %sext_in_reg, 131, implicit-def $nzcv
     ; SELECT-NEXT: %cmp:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
     ; SELECT-NEXT: $w0 = COPY %cmp
     ; SELECT-NEXT: RET_ReallyLR implicit $w0
diff --git a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
index d949e10edce45..a48e656dd2edd 100644
--- a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
+++ b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
@@ -781,36 +781,22 @@ define i1 @almost_immediate_neg_ugt_64(i64 %x) {
 }
 
 define i1 @cmn_nsw(i32 %a, i32 %b) {
-; SDISEL-LABEL: cmn_nsw:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, w1
-; SDISEL-NEXT:    cset w0, gt
-; SDISEL-NEXT:    ret
-;
-; GISEL-LABEL: cmn_nsw:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    neg w8, w1
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, gt
-; GISEL-NEXT:    ret
+; CHECK-LABEL: cmn_nsw:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    cmn w0, w1
+; CHECK-NEXT:    cset w0, gt
+; CHECK-NEXT:    ret
   %sub = sub nsw i32 0, %b
   %cmp = icmp sgt i32 %a, %sub
   ret i1 %cmp
 }
 
 define i1 @cmn_nsw_64(i64 %a, i64 %b) {
-; SDISEL-LABEL: cmn_nsw_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, x1
-; SDISEL-NEXT:    cset w0, gt
-; SDISEL-NEXT:    ret
-;
-; GISEL-LABEL: cmn_nsw_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    neg x8, x1
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, gt
-; GISEL-NEXT:    ret
+; CHECK-LABEL: cmn_nsw_64:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    cmn x0, x1
+; CHECK-NEXT:    cset w0, gt
+; CHECK-NEXT:    ret
   %sub = sub nsw i64 0, %b
   %cmp = icmp sgt i64 %a, %sub
   ret i1 %cmp
@@ -828,6 +814,24 @@ define i1 @cmn_nsw_neg(i32 %a, i32 %b) {
   ret i1 %cmp
 }
 
+define i1 @cmn_swap(i32 %a, i32 %b) {
+; SDISEL-LABEL: cmn_swap:
+; SDISEL:       // %bb.0:
+; SDISEL-NEXT:    cmn w0, w1
+; SDISEL-NEXT:    cset w0, lt
+; SDISEL-NEXT:    ret
+;
+; GISEL-LABEL: cmn_swap:
+; GISEL:       // %bb.0:
+; GISEL-NEXT:    cmn w1, w0
+; GISEL-NEXT:    cset w0, lt
+; GISEL-NEXT:    ret
+  %sub = sub nsw i32 0, %b
+  %cmp = icmp sgt i32 %sub, %a
+  ret i1 %cmp
+}
+
+
 define i1 @cmn_nsw_neg_64(i64 %a, i64 %b) {
 ; CHECK-LABEL: cmn_nsw_neg_64:
 ; CHECK:       // %bb.0:

>From 7163177e9b3f64e8c548608e9268ddf58ad35553 Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Mon, 28 Jul 2025 11:15:41 -0400
Subject: [PATCH 3/4] Update Test

---
 llvm/test/CodeGen/AArch64/cmp-to-cmn.ll | 252 ++++++++++++------------
 1 file changed, 126 insertions(+), 126 deletions(-)

diff --git a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
index a48e656dd2edd..0f52aae1d2877 100644
--- a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
+++ b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
@@ -1,15 +1,15 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
-; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,SDISEL
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,SD
 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s -global-isel | FileCheck %s --check-prefixes=CHECK,GISEL
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "arm64"
 
 define i1 @test_EQ_IllEbT(i64 %a, i64 %b) {
-; SDISEL-LABEL: test_EQ_IllEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x0, x1
-; SDISEL-NEXT:    cset w0, eq
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_EQ_IllEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x0, x1
+; SD-NEXT:    cset w0, eq
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_EQ_IllEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -23,11 +23,11 @@ entry:
 }
 
 define i1 @test_EQ_IliEbT(i64 %a, i32 %b) {
-; SDISEL-LABEL: test_EQ_IliEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x0, w1, sxtw
-; SDISEL-NEXT:    cset w0, eq
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_EQ_IliEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x0, w1, sxtw
+; SD-NEXT:    cset w0, eq
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_EQ_IliEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -70,11 +70,11 @@ entry:
 }
 
 define i1 @test_EQ_IilEbT(i32 %a, i64 %b) {
-; SDISEL-LABEL: test_EQ_IilEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x1, w0, sxtw
-; SDISEL-NEXT:    cset w0, eq
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_EQ_IilEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x1, w0, sxtw
+; SD-NEXT:    cset w0, eq
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_EQ_IilEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -91,11 +91,11 @@ entry:
 }
 
 define i1 @test_EQ_IiiEbT(i32 %a, i32 %b) {
-; SDISEL-LABEL: test_EQ_IiiEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn w0, w1
-; SDISEL-NEXT:    cset w0, eq
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_EQ_IiiEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn w0, w1
+; SD-NEXT:    cset w0, eq
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_EQ_IiiEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -247,11 +247,11 @@ entry:
 }
 
 define i1 @test_NE_IllEbT(i64 %a, i64 %b) {
-; SDISEL-LABEL: test_NE_IllEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x0, x1
-; SDISEL-NEXT:    cset w0, ne
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_NE_IllEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x0, x1
+; SD-NEXT:    cset w0, ne
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_NE_IllEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -265,11 +265,11 @@ entry:
 }
 
 define i1 @test_NE_IliEbT(i64 %a, i32 %b) {
-; SDISEL-LABEL: test_NE_IliEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x0, w1, sxtw
-; SDISEL-NEXT:    cset w0, ne
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_NE_IliEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x0, w1, sxtw
+; SD-NEXT:    cset w0, ne
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_NE_IliEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -312,11 +312,11 @@ entry:
 }
 
 define i1 @test_NE_IilEbT(i32 %a, i64 %b) {
-; SDISEL-LABEL: test_NE_IilEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn x1, w0, sxtw
-; SDISEL-NEXT:    cset w0, ne
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_NE_IilEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn x1, w0, sxtw
+; SD-NEXT:    cset w0, ne
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_NE_IilEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -333,11 +333,11 @@ entry:
 }
 
 define i1 @test_NE_IiiEbT(i32 %a, i32 %b) {
-; SDISEL-LABEL: test_NE_IiiEbT:
-; SDISEL:       // %bb.0: // %entry
-; SDISEL-NEXT:    cmn w0, w1
-; SDISEL-NEXT:    cset w0, ne
-; SDISEL-NEXT:    ret
+; SD-LABEL: test_NE_IiiEbT:
+; SD:       // %bb.0: // %entry
+; SD-NEXT:    cmn w0, w1
+; SD-NEXT:    cset w0, ne
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: test_NE_IiiEbT:
 ; GISEL:       // %bb.0: // %entry
@@ -501,11 +501,11 @@ define i1 @cmn_large_imm(i32 %a) {
 }
 
 define i1 @almost_immediate_neg_slt(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_slt:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, le
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_slt:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, le
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_slt:
 ; GISEL:       // %bb.0:
@@ -519,11 +519,11 @@ define i1 @almost_immediate_neg_slt(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_slt_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_slt_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, le
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_slt_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, le
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_slt_64:
 ; GISEL:       // %bb.0:
@@ -537,11 +537,11 @@ define i1 @almost_immediate_neg_slt_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_sge(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sge:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, gt
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sge:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, gt
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sge:
 ; GISEL:       // %bb.0:
@@ -555,11 +555,11 @@ define i1 @almost_immediate_neg_sge(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_sge_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sge_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, gt
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sge_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, gt
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sge_64:
 ; GISEL:       // %bb.0:
@@ -573,11 +573,11 @@ define i1 @almost_immediate_neg_sge_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_uge(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_uge:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, hi
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_uge:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, hi
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_uge:
 ; GISEL:       // %bb.0:
@@ -591,11 +591,11 @@ define i1 @almost_immediate_neg_uge(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_uge_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_uge_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, hi
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_uge_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, hi
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_uge_64:
 ; GISEL:       // %bb.0:
@@ -609,11 +609,11 @@ define i1 @almost_immediate_neg_uge_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_ult(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ult:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, ls
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ult:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, ls
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ult:
 ; GISEL:       // %bb.0:
@@ -627,11 +627,11 @@ define i1 @almost_immediate_neg_ult(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_ult_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ult_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4079, lsl #12 // =16707584
-; SDISEL-NEXT:    cset w0, ls
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ult_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4079, lsl #12 // =16707584
+; SD-NEXT:    cset w0, ls
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ult_64:
 ; GISEL:       // %bb.0:
@@ -645,11 +645,11 @@ define i1 @almost_immediate_neg_ult_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_sle(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sle:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, lt
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sle:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, lt
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sle:
 ; GISEL:       // %bb.0:
@@ -662,11 +662,11 @@ define i1 @almost_immediate_neg_sle(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_sle_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sle_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, lt
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sle_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, lt
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sle_64:
 ; GISEL:       // %bb.0:
@@ -679,11 +679,11 @@ define i1 @almost_immediate_neg_sle_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_sgt(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sgt:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, ge
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sgt:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, ge
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sgt:
 ; GISEL:       // %bb.0:
@@ -696,11 +696,11 @@ define i1 @almost_immediate_neg_sgt(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_sgt_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_sgt_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, ge
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_sgt_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, ge
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_sgt_64:
 ; GISEL:       // %bb.0:
@@ -713,11 +713,11 @@ define i1 @almost_immediate_neg_sgt_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_ule(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ule:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, lo
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ule:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, lo
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ule:
 ; GISEL:       // %bb.0:
@@ -730,11 +730,11 @@ define i1 @almost_immediate_neg_ule(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_ule_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ule_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, lo
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ule_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, lo
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ule_64:
 ; GISEL:       // %bb.0:
@@ -747,11 +747,11 @@ define i1 @almost_immediate_neg_ule_64(i64 %x) {
 }
 
 define i1 @almost_immediate_neg_ugt(i32 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ugt:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, hs
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ugt:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, hs
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ugt:
 ; GISEL:       // %bb.0:
@@ -764,11 +764,11 @@ define i1 @almost_immediate_neg_ugt(i32 %x) {
 }
 
 define i1 @almost_immediate_neg_ugt_64(i64 %x) {
-; SDISEL-LABEL: almost_immediate_neg_ugt_64:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn x0, #4095, lsl #12 // =16773120
-; SDISEL-NEXT:    cset w0, hs
-; SDISEL-NEXT:    ret
+; SD-LABEL: almost_immediate_neg_ugt_64:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn x0, #4095, lsl #12 // =16773120
+; SD-NEXT:    cset w0, hs
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: almost_immediate_neg_ugt_64:
 ; GISEL:       // %bb.0:
@@ -815,11 +815,11 @@ define i1 @cmn_nsw_neg(i32 %a, i32 %b) {
 }
 
 define i1 @cmn_swap(i32 %a, i32 %b) {
-; SDISEL-LABEL: cmn_swap:
-; SDISEL:       // %bb.0:
-; SDISEL-NEXT:    cmn w0, w1
-; SDISEL-NEXT:    cset w0, lt
-; SDISEL-NEXT:    ret
+; SD-LABEL: cmn_swap:
+; SD:       // %bb.0:
+; SD-NEXT:    cmn w0, w1
+; SD-NEXT:    cset w0, lt
+; SD-NEXT:    ret
 ;
 ; GISEL-LABEL: cmn_swap:
 ; GISEL:       // %bb.0:

>From c229104588ae210978582e2953acfb8f6efb4b2c Mon Sep 17 00:00:00 2001
From: AZero13 <gfunni234 at gmail.com>
Date: Mon, 28 Jul 2025 11:16:21 -0400
Subject: [PATCH 4/4] Update test

---
 llvm/test/CodeGen/AArch64/cmp-to-cmn.ll | 316 ++++++++++++------------
 1 file changed, 158 insertions(+), 158 deletions(-)

diff --git a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
index 0f52aae1d2877..4b0ad0f429aec 100644
--- a/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
+++ b/llvm/test/CodeGen/AArch64/cmp-to-cmn.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
 ; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s | FileCheck %s --check-prefixes=CHECK,SD
-; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s -global-isel | FileCheck %s --check-prefixes=CHECK,GISEL
+; RUN: llc -mtriple=aarch64-unknown-linux-gnu < %s -global-isel | FileCheck %s --check-prefixes=CHECK,GI
 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
 target triple = "arm64"
 
@@ -11,11 +11,11 @@ define i1 @test_EQ_IllEbT(i64 %a, i64 %b) {
 ; SD-NEXT:    cset w0, eq
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_EQ_IllEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    cmn x1, x0
-; GISEL-NEXT:    cset w0, eq
-; GISEL-NEXT:    ret
+; GI-LABEL: test_EQ_IllEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    cmn x1, x0
+; GI-NEXT:    cset w0, eq
+; GI-NEXT:    ret
 entry:
   %add = sub i64 0, %b
   %cmp = icmp eq i64 %add, %a
@@ -29,13 +29,13 @@ define i1 @test_EQ_IliEbT(i64 %a, i32 %b) {
 ; SD-NEXT:    cset w0, eq
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_EQ_IliEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    // kill: def $w1 killed $w1 def $x1
-; GISEL-NEXT:    sxtw x8, w1
-; GISEL-NEXT:    cmn x8, x0
-; GISEL-NEXT:    cset w0, eq
-; GISEL-NEXT:    ret
+; GI-LABEL: test_EQ_IliEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    // kill: def $w1 killed $w1 def $x1
+; GI-NEXT:    sxtw x8, w1
+; GI-NEXT:    cmn x8, x0
+; GI-NEXT:    cset w0, eq
+; GI-NEXT:    ret
 entry:
   %conv = sext i32 %b to i64
   %add = sub i64 0, %a
@@ -76,13 +76,13 @@ define i1 @test_EQ_IilEbT(i32 %a, i64 %b) {
 ; SD-NEXT:    cset w0, eq
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_EQ_IilEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    // kill: def $w0 killed $w0 def $x0
-; GISEL-NEXT:    sxtw x8, w0
-; GISEL-NEXT:    cmn x8, x1
-; GISEL-NEXT:    cset w0, eq
-; GISEL-NEXT:    ret
+; GI-LABEL: test_EQ_IilEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    // kill: def $w0 killed $w0 def $x0
+; GI-NEXT:    sxtw x8, w0
+; GI-NEXT:    cmn x8, x1
+; GI-NEXT:    cset w0, eq
+; GI-NEXT:    ret
 entry:
   %conv = sext i32 %a to i64
   %add = sub i64 0, %b
@@ -97,11 +97,11 @@ define i1 @test_EQ_IiiEbT(i32 %a, i32 %b) {
 ; SD-NEXT:    cset w0, eq
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_EQ_IiiEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    cmn w1, w0
-; GISEL-NEXT:    cset w0, eq
-; GISEL-NEXT:    ret
+; GI-LABEL: test_EQ_IiiEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    cmn w1, w0
+; GI-NEXT:    cset w0, eq
+; GI-NEXT:    ret
 entry:
   %add = sub i32 0, %b
   %cmp = icmp eq i32 %add, %a
@@ -253,11 +253,11 @@ define i1 @test_NE_IllEbT(i64 %a, i64 %b) {
 ; SD-NEXT:    cset w0, ne
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_NE_IllEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    cmn x1, x0
-; GISEL-NEXT:    cset w0, ne
-; GISEL-NEXT:    ret
+; GI-LABEL: test_NE_IllEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    cmn x1, x0
+; GI-NEXT:    cset w0, ne
+; GI-NEXT:    ret
 entry:
   %add = sub i64 0, %b
   %cmp = icmp ne i64 %add, %a
@@ -271,13 +271,13 @@ define i1 @test_NE_IliEbT(i64 %a, i32 %b) {
 ; SD-NEXT:    cset w0, ne
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_NE_IliEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    // kill: def $w1 killed $w1 def $x1
-; GISEL-NEXT:    sxtw x8, w1
-; GISEL-NEXT:    cmn x8, x0
-; GISEL-NEXT:    cset w0, ne
-; GISEL-NEXT:    ret
+; GI-LABEL: test_NE_IliEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    // kill: def $w1 killed $w1 def $x1
+; GI-NEXT:    sxtw x8, w1
+; GI-NEXT:    cmn x8, x0
+; GI-NEXT:    cset w0, ne
+; GI-NEXT:    ret
 entry:
   %conv = sext i32 %b to i64
   %add = sub i64 0, %a
@@ -318,13 +318,13 @@ define i1 @test_NE_IilEbT(i32 %a, i64 %b) {
 ; SD-NEXT:    cset w0, ne
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_NE_IilEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    // kill: def $w0 killed $w0 def $x0
-; GISEL-NEXT:    sxtw x8, w0
-; GISEL-NEXT:    cmn x8, x1
-; GISEL-NEXT:    cset w0, ne
-; GISEL-NEXT:    ret
+; GI-LABEL: test_NE_IilEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    // kill: def $w0 killed $w0 def $x0
+; GI-NEXT:    sxtw x8, w0
+; GI-NEXT:    cmn x8, x1
+; GI-NEXT:    cset w0, ne
+; GI-NEXT:    ret
 entry:
   %conv = sext i32 %a to i64
   %add = sub i64 0, %b
@@ -339,11 +339,11 @@ define i1 @test_NE_IiiEbT(i32 %a, i32 %b) {
 ; SD-NEXT:    cset w0, ne
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: test_NE_IiiEbT:
-; GISEL:       // %bb.0: // %entry
-; GISEL-NEXT:    cmn w1, w0
-; GISEL-NEXT:    cset w0, ne
-; GISEL-NEXT:    ret
+; GI-LABEL: test_NE_IiiEbT:
+; GI:       // %bb.0: // %entry
+; GI-NEXT:    cmn w1, w0
+; GI-NEXT:    cset w0, ne
+; GI-NEXT:    ret
 entry:
   %add = sub i32 0, %b
   %cmp = icmp ne i32 %add, %a
@@ -507,13 +507,13 @@ define i1 @almost_immediate_neg_slt(i32 %x) {
 ; SD-NEXT:    cset w0, le
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_slt:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #4097 // =0x1001
-; GISEL-NEXT:    movk w8, #65281, lsl #16
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, lt
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_slt:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #4097 // =0x1001
+; GI-NEXT:    movk w8, #65281, lsl #16
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, lt
+; GI-NEXT:    ret
   %cmp = icmp slt i32 %x, -16707583
   ret i1 %cmp
 }
@@ -525,13 +525,13 @@ define i1 @almost_immediate_neg_slt_64(i64 %x) {
 ; SD-NEXT:    cset w0, le
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_slt_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
-; GISEL-NEXT:    movk x8, #65281, lsl #16
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, lt
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_slt_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GI-NEXT:    movk x8, #65281, lsl #16
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, lt
+; GI-NEXT:    ret
   %cmp = icmp slt i64 %x, -16707583
   ret i1 %cmp
 }
@@ -543,13 +543,13 @@ define i1 @almost_immediate_neg_sge(i32 %x) {
 ; SD-NEXT:    cset w0, gt
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sge:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #4097 // =0x1001
-; GISEL-NEXT:    movk w8, #65281, lsl #16
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, ge
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sge:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #4097 // =0x1001
+; GI-NEXT:    movk w8, #65281, lsl #16
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, ge
+; GI-NEXT:    ret
   %cmp = icmp sge i32 %x, -16707583
   ret i1 %cmp
 }
@@ -561,13 +561,13 @@ define i1 @almost_immediate_neg_sge_64(i64 %x) {
 ; SD-NEXT:    cset w0, gt
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sge_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
-; GISEL-NEXT:    movk x8, #65281, lsl #16
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, ge
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sge_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GI-NEXT:    movk x8, #65281, lsl #16
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, ge
+; GI-NEXT:    ret
   %cmp = icmp sge i64 %x, -16707583
   ret i1 %cmp
 }
@@ -579,13 +579,13 @@ define i1 @almost_immediate_neg_uge(i32 %x) {
 ; SD-NEXT:    cset w0, hi
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_uge:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #4097 // =0x1001
-; GISEL-NEXT:    movk w8, #65281, lsl #16
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, hs
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_uge:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #4097 // =0x1001
+; GI-NEXT:    movk w8, #65281, lsl #16
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, hs
+; GI-NEXT:    ret
   %cmp = icmp uge i32 %x, -16707583
   ret i1 %cmp
 }
@@ -597,13 +597,13 @@ define i1 @almost_immediate_neg_uge_64(i64 %x) {
 ; SD-NEXT:    cset w0, hi
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_uge_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
-; GISEL-NEXT:    movk x8, #65281, lsl #16
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, hs
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_uge_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GI-NEXT:    movk x8, #65281, lsl #16
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, hs
+; GI-NEXT:    ret
   %cmp = icmp uge i64 %x, -16707583
   ret i1 %cmp
 }
@@ -615,13 +615,13 @@ define i1 @almost_immediate_neg_ult(i32 %x) {
 ; SD-NEXT:    cset w0, ls
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ult:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #4097 // =0x1001
-; GISEL-NEXT:    movk w8, #65281, lsl #16
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, lo
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ult:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #4097 // =0x1001
+; GI-NEXT:    movk w8, #65281, lsl #16
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, lo
+; GI-NEXT:    ret
   %cmp = icmp ult i32 %x, -16707583
   ret i1 %cmp
 }
@@ -633,13 +633,13 @@ define i1 @almost_immediate_neg_ult_64(i64 %x) {
 ; SD-NEXT:    cset w0, ls
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ult_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
-; GISEL-NEXT:    movk x8, #65281, lsl #16
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, lo
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ult_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-61439 // =0xffffffffffff1001
+; GI-NEXT:    movk x8, #65281, lsl #16
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, lo
+; GI-NEXT:    ret
   %cmp = icmp ult i64 %x, -16707583
   ret i1 %cmp
 }
@@ -651,12 +651,12 @@ define i1 @almost_immediate_neg_sle(i32 %x) {
 ; SD-NEXT:    cset w0, lt
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sle:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, le
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sle:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, le
+; GI-NEXT:    ret
   %cmp = icmp sle i32 %x, -16773121
   ret i1 %cmp
 }
@@ -668,12 +668,12 @@ define i1 @almost_immediate_neg_sle_64(i64 %x) {
 ; SD-NEXT:    cset w0, lt
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sle_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, le
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sle_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, le
+; GI-NEXT:    ret
   %cmp = icmp sle i64 %x, -16773121
   ret i1 %cmp
 }
@@ -685,12 +685,12 @@ define i1 @almost_immediate_neg_sgt(i32 %x) {
 ; SD-NEXT:    cset w0, ge
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sgt:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, gt
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sgt:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, gt
+; GI-NEXT:    ret
   %cmp = icmp sgt i32 %x, -16773121
   ret i1 %cmp
 }
@@ -702,12 +702,12 @@ define i1 @almost_immediate_neg_sgt_64(i64 %x) {
 ; SD-NEXT:    cset w0, ge
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_sgt_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, gt
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_sgt_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, gt
+; GI-NEXT:    ret
   %cmp = icmp sgt i64 %x, -16773121
   ret i1 %cmp
 }
@@ -719,12 +719,12 @@ define i1 @almost_immediate_neg_ule(i32 %x) {
 ; SD-NEXT:    cset w0, lo
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ule:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, ls
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ule:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, ls
+; GI-NEXT:    ret
   %cmp = icmp ule i32 %x, -16773121
   ret i1 %cmp
 }
@@ -736,12 +736,12 @@ define i1 @almost_immediate_neg_ule_64(i64 %x) {
 ; SD-NEXT:    cset w0, lo
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ule_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, ls
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ule_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, ls
+; GI-NEXT:    ret
   %cmp = icmp ule i64 %x, -16773121
   ret i1 %cmp
 }
@@ -753,12 +753,12 @@ define i1 @almost_immediate_neg_ugt(i32 %x) {
 ; SD-NEXT:    cset w0, hs
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ugt:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov w8, #-16773121 // =0xff000fff
-; GISEL-NEXT:    cmp w0, w8
-; GISEL-NEXT:    cset w0, hi
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ugt:
+; GI:       // %bb.0:
+; GI-NEXT:    mov w8, #-16773121 // =0xff000fff
+; GI-NEXT:    cmp w0, w8
+; GI-NEXT:    cset w0, hi
+; GI-NEXT:    ret
   %cmp = icmp ugt i32 %x, -16773121
   ret i1 %cmp
 }
@@ -770,12 +770,12 @@ define i1 @almost_immediate_neg_ugt_64(i64 %x) {
 ; SD-NEXT:    cset w0, hs
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: almost_immediate_neg_ugt_64:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
-; GISEL-NEXT:    cmp x0, x8
-; GISEL-NEXT:    cset w0, hi
-; GISEL-NEXT:    ret
+; GI-LABEL: almost_immediate_neg_ugt_64:
+; GI:       // %bb.0:
+; GI-NEXT:    mov x8, #-16773121 // =0xffffffffff000fff
+; GI-NEXT:    cmp x0, x8
+; GI-NEXT:    cset w0, hi
+; GI-NEXT:    ret
   %cmp = icmp ugt i64 %x, -16773121
   ret i1 %cmp
 }
@@ -821,11 +821,11 @@ define i1 @cmn_swap(i32 %a, i32 %b) {
 ; SD-NEXT:    cset w0, lt
 ; SD-NEXT:    ret
 ;
-; GISEL-LABEL: cmn_swap:
-; GISEL:       // %bb.0:
-; GISEL-NEXT:    cmn w1, w0
-; GISEL-NEXT:    cset w0, lt
-; GISEL-NEXT:    ret
+; GI-LABEL: cmn_swap:
+; GI:       // %bb.0:
+; GI-NEXT:    cmn w1, w0
+; GI-NEXT:    cset w0, lt
+; GI-NEXT:    ret
   %sub = sub nsw i32 0, %b
   %cmp = icmp sgt i32 %sub, %a
   ret i1 %cmp



More information about the llvm-commits mailing list