[llvm] [GlobalISel] Combine into abd[su] and legalize abd[su] (PR #118865)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 6 09:59:28 PST 2024


================
@@ -379,21 +577,34 @@ define <8 x i16> @abds_const_zero(<8 x i16> %src1) {
 }
 
 define <8 x i16> @abds_const_both() {
-; CHECK-LABEL: abds_const_both:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    movi v0.8h, #2
-; CHECK-NEXT:    ret
+; CHECK-SD-LABEL: abds_const_both:
+; CHECK-SD:       // %bb.0:
+; CHECK-SD-NEXT:    movi v0.8h, #2
+; CHECK-SD-NEXT:    ret
+;
+; CHECK-GI-LABEL: abds_const_both:
+; CHECK-GI:       // %bb.0:
+; CHECK-GI-NEXT:    movi v0.4s, #2
+; CHECK-GI-NEXT:    abs v0.4s, v0.4s
+; CHECK-GI-NEXT:    uzp1 v0.8h, v0.8h, v0.8h
+; CHECK-GI-NEXT:    ret
   %sub = sub <8 x i32> <i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3, i32 3>, <i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1, i32 1>
   %abs = call <8 x i32> @llvm.abs.v8i32(<8 x i32> %sub, i1 0)
   %result = trunc <8 x i32> %abs to <8 x i16>
   ret <8 x i16> %result
 }
 
 define <8 x i16> @abds_const_bothhigh() {
-; CHECK-LABEL: abds_const_bothhigh:
-; CHECK:       // %bb.0:
-; CHECK-NEXT:    movi v0.8h, #1
-; CHECK-NEXT:    ret
+; CHECK-SD-LABEL: abds_const_bothhigh:
+; CHECK-SD:       // %bb.0:
+; CHECK-SD-NEXT:    movi v0.8h, #1
+; CHECK-SD-NEXT:    ret
+;
+; CHECK-GI-LABEL: abds_const_bothhigh:
+; CHECK-GI:       // %bb.0:
+; CHECK-GI-NEXT:    mvni v0.8h, #1
+; CHECK-GI-NEXT:    sabd v0.8h, v0.8h, v0.8h
----------------
tschuett wrote:

Common problem. In the trunc of abs combine.

https://github.com/llvm/llvm-project/pull/118865


More information about the llvm-commits mailing list