[llvm] afa4438 - [InstSimplify] add tests for cttz of shifted-1; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 8 13:31:12 PST 2021


Author: Sanjay Patel
Date: 2021-03-08T16:30:13-05:00
New Revision: afa443831bfd6f7ec858aa19dcb21a74d08d8c79

URL: https://github.com/llvm/llvm-project/commit/afa443831bfd6f7ec858aa19dcb21a74d08d8c79
DIFF: https://github.com/llvm/llvm-project/commit/afa443831bfd6f7ec858aa19dcb21a74d08d8c79.diff

LOG: [InstSimplify] add tests for cttz of shifted-1; NFC

Added: 
    

Modified: 
    llvm/test/Transforms/InstSimplify/call.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll
index 328626e4d1ce..c89f0048237e 100644
--- a/llvm/test/Transforms/InstSimplify/call.ll
+++ b/llvm/test/Transforms/InstSimplify/call.ll
@@ -1360,4 +1360,29 @@ define i1 @ctpop_bool(i1 %x) {
   ret i1 %r
 }
 
+declare i32 @llvm.cttz.i32(i32, i1)
+declare <3 x i33> @llvm.cttz.v3i33(<3 x i33>, i1)
+
+define i32 @cttz_shl1(i32 %x) {
+; CHECK-LABEL: @cttz_shl1(
+; CHECK-NEXT:    [[S:%.*]] = shl i32 1, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = call i32 @llvm.cttz.i32(i32 [[S]], i1 true)
+; CHECK-NEXT:    ret i32 [[R]]
+;
+  %s = shl i32 1, %x
+  %r = call i32 @llvm.cttz.i32(i32 %s, i1 true)
+  ret i32 %r
+}
+
+define <3 x i33> @cttz_shl1_vec(<3 x i33> %x) {
+; CHECK-LABEL: @cttz_shl1_vec(
+; CHECK-NEXT:    [[S:%.*]] = shl <3 x i33> <i33 1, i33 1, i33 undef>, [[X:%.*]]
+; CHECK-NEXT:    [[R:%.*]] = call <3 x i33> @llvm.cttz.v3i33(<3 x i33> [[S]], i1 false)
+; CHECK-NEXT:    ret <3 x i33> [[R]]
+;
+  %s = shl <3 x i33> <i33 1, i33 1, i33 undef>, %x
+  %r = call <3 x i33> @llvm.cttz.v3i33(<3 x i33> %s, i1 false)
+  ret <3 x i33> %r
+}
+
 attributes #0 = { nobuiltin readnone }


        


More information about the llvm-commits mailing list