[llvm] [AArch64] Signed comparison using CMN is safe when the subtraction is nsw (PR #141993)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 11 12:17:24 PDT 2025
================
@@ -602,3 +602,49 @@ define i1 @almost_immediate_neg_ugt_64(i64 %x) {
%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
+%sub = sub nsw i32 0, %b
+%cmp = icmp sgt i32 %a, %sub
+ret i1 %cmp
----------------
davemgreen wrote:
Indent the code in the function a little
https://github.com/llvm/llvm-project/pull/141993
More information about the llvm-commits
mailing list