[llvm] b142e9d - [InstCombine] add tests for popcount with zext operand; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 29 12:07:33 PDT 2021


Author: Sanjay Patel
Date: 2021-04-29T15:07:16-04:00
New Revision: b142e9d1c5170baad39dee3e800032460554551a

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

LOG: [InstCombine] add tests for popcount with zext operand; NFC

PR50141

Added: 
    

Modified: 
    llvm/test/Transforms/InstCombine/ctpop.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/ctpop.ll b/llvm/test/Transforms/InstCombine/ctpop.ll
index bdb8e6aabe89..617506fc7f6a 100644
--- a/llvm/test/Transforms/InstCombine/ctpop.ll
+++ b/llvm/test/Transforms/InstCombine/ctpop.ll
@@ -346,3 +346,38 @@ define <2 x i32> @sub_ctpop_vec_extra_use(<2 x i32> %a, <2 x i32>* %p) {
   %res = sub <2 x i32> <i32 32, i32 32>, %cnt
   ret <2 x i32> %res
 }
+
+define i32 @zext_ctpop(i16 %x) {
+; CHECK-LABEL: @zext_ctpop(
+; CHECK-NEXT:    [[Z:%.*]] = zext i16 [[X:%.*]] to i32
+; CHECK-NEXT:    [[P:%.*]] = call i32 @llvm.ctpop.i32(i32 [[Z]]), !range [[RNG3:![0-9]+]]
+; CHECK-NEXT:    ret i32 [[P]]
+;
+  %z = zext i16 %x to i32
+  %p = call i32 @llvm.ctpop.i32(i32 %z)
+  ret i32 %p
+}
+
+define <2 x i32> @zext_ctpop_vec(<2 x i7> %x) {
+; CHECK-LABEL: @zext_ctpop_vec(
+; CHECK-NEXT:    [[Z:%.*]] = zext <2 x i7> [[X:%.*]] to <2 x i32>
+; CHECK-NEXT:    [[P:%.*]] = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> [[Z]])
+; CHECK-NEXT:    ret <2 x i32> [[P]]
+;
+  %z = zext <2 x i7> %x to <2 x i32>
+  %p = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %z)
+  ret <2 x i32> %p
+}
+
+define i32 @zext_ctpop_extra_use(i16 %x, i32* %q) {
+; CHECK-LABEL: @zext_ctpop_extra_use(
+; CHECK-NEXT:    [[Z:%.*]] = zext i16 [[X:%.*]] to i32
+; CHECK-NEXT:    store i32 [[Z]], i32* [[Q:%.*]], align 4
+; CHECK-NEXT:    [[P:%.*]] = call i32 @llvm.ctpop.i32(i32 [[Z]]), !range [[RNG3]]
+; CHECK-NEXT:    ret i32 [[P]]
+;
+  %z = zext i16 %x to i32
+  store i32 %z, i32* %q
+  %p = call i32 @llvm.ctpop.i32(i32 %z)
+  ret i32 %p
+}


        


More information about the llvm-commits mailing list