[llvm] [AArch64] Use isKnownNonZero to optimize eligible compares to cmn (PR #96349)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 28 00:12:37 PDT 2024
================
@@ -258,3 +258,34 @@ define i32 @neg_range_int(i32 %a, i32 %b, i32 %c) {
ret i32 %retval.0
}
+; (b > -3 || a < -(c | 1))
+define i32 @neg_range_int_cmn(i32 %a, i32 %b, i32 %c) {
----------------
davemgreen wrote:
In the new code in this test:
```
define i32 @or_neg(i32 %x, i32 %y) {
; CHECK-LABEL: or_neg:
; CHECK: // %bb.0:
; CHECK-NEXT: orr w8, w0, #0x1
; CHECK-NEXT: cmn w8, w1
; CHECK-NEXT: cset w0, gt
; CHECK-NEXT: ret
%3 = or i32 %x, 1
%4 = sub i32 0, %3
%5 = icmp sgt i32 %4, %y
%6 = zext i1 %5 to i32
ret i32 %6
}
```
If, say, x==0, y==0 then is the result not backwards?
https://github.com/llvm/llvm-project/pull/96349
More information about the llvm-commits
mailing list