[llvm] 9bcb437 - [InstSimplify] add tests for ctlz constant range; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 23 06:03:39 PDT 2020


Author: Sanjay Patel
Date: 2020-10-23T08:43:45-04:00
New Revision: 9bcb437f46fedbf4f56262ab50721e87fdfc3589

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

LOG: [InstSimplify] add tests for ctlz constant range; NFC

This is a search-and-replace of f6cb7f3.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstSimplify/compare.ll b/llvm/test/Transforms/InstSimplify/compare.ll
index 592e8c6d7cbc..311d8ebebc16 100644
--- a/llvm/test/Transforms/InstSimplify/compare.ll
+++ b/llvm/test/Transforms/InstSimplify/compare.ll
@@ -2160,4 +2160,111 @@ define <2 x i1> @ctpop_slt_bitwidth_splat(<2 x i13> %x) {
   ret <2 x i1> %cmp
 }
 
+declare i11 @llvm.ctlz.i11(i11)
+declare i73 @llvm.ctlz.i73(i73)
+declare <2 x i13> @llvm.ctlz.v2i13(<2 x i13>)
+
+define i1 @ctlz_sgt_bitwidth(i11 %x) {
+; CHECK-LABEL: @ctlz_sgt_bitwidth(
+; CHECK-NEXT:    [[POP:%.*]] = call i11 @llvm.ctlz.i11(i11 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt i11 [[POP]], 11
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i11 @llvm.ctlz.i11(i11 %x)
+  %cmp = icmp sgt i11 %pop, 11
+  ret i1 %cmp
+}
+
+define i1 @ctlz_sle_minus1(i11 %x) {
+; CHECK-LABEL: @ctlz_sle_minus1(
+; CHECK-NEXT:    [[POP:%.*]] = call i11 @llvm.ctlz.i11(i11 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp sle i11 [[POP]], -1
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i11 @llvm.ctlz.i11(i11 %x)
+  %cmp = icmp sle i11 %pop, -1
+  ret i1 %cmp
+}
+
+define i1 @ctlz_ugt_bitwidth(i73 %x) {
+; CHECK-LABEL: @ctlz_ugt_bitwidth(
+; CHECK-NEXT:    [[POP:%.*]] = call i73 @llvm.ctlz.i73(i73 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i73 [[POP]], 73
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i73 @llvm.ctlz.i73(i73 %x)
+  %cmp = icmp ugt i73 %pop, 73
+  ret i1 %cmp
+}
+
+; Negative test - does not simplify, but instcombine could reduce this.
+
+define i1 @ctlz_ugt_bitwidth_minus1(i73 %x) {
+; CHECK-LABEL: @ctlz_ugt_bitwidth_minus1(
+; CHECK-NEXT:    [[POP:%.*]] = call i73 @llvm.ctlz.i73(i73 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i73 [[POP]], 72
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i73 @llvm.ctlz.i73(i73 %x)
+  %cmp = icmp ugt i73 %pop, 72
+  ret i1 %cmp
+}
+
+define <2 x i1> @ctlz_sgt_bitwidth_splat(<2 x i13> %x) {
+; CHECK-LABEL: @ctlz_sgt_bitwidth_splat(
+; CHECK-NEXT:    [[POP:%.*]] = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp sgt <2 x i13> [[POP]], <i13 13, i13 13>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %pop = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> %x)
+  %cmp = icmp sgt <2 x i13> %pop, <i13 13, i13 13>
+  ret <2 x i1> %cmp
+}
+
+define i1 @ctlz_ult_plus1_bitwidth(i11 %x) {
+; CHECK-LABEL: @ctlz_ult_plus1_bitwidth(
+; CHECK-NEXT:    [[POP:%.*]] = call i11 @llvm.ctlz.i11(i11 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i11 [[POP]], 12
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i11 @llvm.ctlz.i11(i11 %x)
+  %cmp = icmp ult i11 %pop, 12
+  ret i1 %cmp
+}
+
+define i1 @ctlz_ne_big_bitwidth(i73 %x) {
+; CHECK-LABEL: @ctlz_ne_big_bitwidth(
+; CHECK-NEXT:    [[POP:%.*]] = call i73 @llvm.ctlz.i73(i73 [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i73 [[POP]], 75
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %pop = call i73 @llvm.ctlz.i73(i73 %x)
+  %cmp = icmp ne i73 %pop, 75
+  ret i1 %cmp
+}
+
+define <2 x i1> @ctlz_slt_bitwidth_plus1_splat(<2 x i13> %x) {
+; CHECK-LABEL: @ctlz_slt_bitwidth_plus1_splat(
+; CHECK-NEXT:    [[POP:%.*]] = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt <2 x i13> [[POP]], <i13 14, i13 14>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %pop = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> %x)
+  %cmp = icmp slt <2 x i13> %pop, <i13 14, i13 14>
+  ret <2 x i1> %cmp
+}
+
+; Negative test - does not simplify, but instcombine could reduce this.
+
+define <2 x i1> @ctlz_slt_bitwidth_splat(<2 x i13> %x) {
+; CHECK-LABEL: @ctlz_slt_bitwidth_splat(
+; CHECK-NEXT:    [[POP:%.*]] = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> [[X:%.*]], i1 false)
+; CHECK-NEXT:    [[CMP:%.*]] = icmp slt <2 x i13> [[POP]], <i13 13, i13 13>
+; CHECK-NEXT:    ret <2 x i1> [[CMP]]
+;
+  %pop = call <2 x i13> @llvm.ctlz.v2i13(<2 x i13> %x)
+  %cmp = icmp slt <2 x i13> %pop, <i13 13, i13 13>
+  ret <2 x i1> %cmp
+}
+
 attributes #0 = { null_pointer_is_valid }


        


More information about the llvm-commits mailing list