[llvm] [AArch64][SVE2] Lower read-after-write mask to whilerw (PR #114028)
Graham Hunter via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 30 05:12:15 PDT 2024
================
@@ -30,6 +30,36 @@ entry:
ret <vscale x 16 x i1> %active.lane.mask.alias
}
+define <vscale x 16 x i1> @whilerw_8(ptr noalias %a, ptr %b, ptr %c, i32 %n) {
+; CHECK-LABEL: whilerw_8:
+; CHECK: // %bb.0: // %entry
+; CHECK-NEXT: whilerw p0.b, x2, x1
+; CHECK-NEXT: ret
+;
+; CHECK-NOSVE2-LABEL: whilerw_8:
+; CHECK-NOSVE2: // %bb.0: // %entry
+; CHECK-NOSVE2-NEXT: subs x8, x2, x1
+; CHECK-NOSVE2-NEXT: cneg x8, x8, mi
+; CHECK-NOSVE2-NEXT: cmp x8, #0
+; CHECK-NOSVE2-NEXT: cset w9, lt
+; CHECK-NOSVE2-NEXT: whilelo p0.b, xzr, x8
+; CHECK-NOSVE2-NEXT: sbfx x8, x9, #0, #1
+; CHECK-NOSVE2-NEXT: whilelo p1.b, xzr, x8
+; CHECK-NOSVE2-NEXT: sel p0.b, p0, p0.b, p1.b
+; CHECK-NOSVE2-NEXT: ret
+entry:
+ %b24 = ptrtoint ptr %b to i64
+ %c25 = ptrtoint ptr %c to i64
+ %sub.diff = sub i64 %c25, %b24
+ %0 = tail call i64 @llvm.abs.i64(i64 %sub.diff, i1 false)
+ %neg.compare = icmp slt i64 %0, 0
----------------
huntergr-arm wrote:
This comparison is incorrect -- you shouldn't get a negative value after calling `abs`, and the ref manual indicates it should just be an equality comparison against 0 to combine with the `e < diff` comparison. I'm not sure what to do in the case of the diff being the signed minimum, though it seems unlikely to occur in practice.
I think we got the original code for whilewr wrong too -- should be `sle` against 0 instead of `slt`.
https://github.com/llvm/llvm-project/pull/114028
More information about the llvm-commits
mailing list