[llvm] [AArch64] Allow splitting bitmasks for ANDS. (PR #149095)
Ricardo Jesus via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 18 01:47:31 PDT 2025
================
@@ -263,3 +263,110 @@ entry:
%conv = zext i1 %cmp to i8
ret i8 %conv
}
+
+; Test ANDS.
+define i32 @test1_ands(i32 %a) {
+; CHECK-LABEL: test1_ands:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: and w8, w0, #0x3ffc00
+; CHECK-NEXT: ands w8, w8, #0xffe007ff
+; CHECK-NEXT: csel w0, w8, wzr, eq
+; CHECK-NEXT: ret
+entry:
+ %ands = and i32 %a, 2098176
+ %c = icmp eq i32 %ands, 0
+ %r = select i1 %c, i32 %ands, i32 0
+ ret i32 %r
----------------
rj-jesus wrote:
Ah, of course, what do you think of the following (`ands == 0 ? a : ands`)?
```llvm
%ands = and i64 %a, 2098176
%c = icmp eq i64 %ands, 0
%r = select i1 %c, i64 %a, i64 %ands
```
https://github.com/llvm/llvm-project/pull/149095
More information about the llvm-commits
mailing list