[llvm] b7e9ef7 - [InstCombine] Add conjugate part of pre-commit tests for PR57328. NFC.

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 24 10:49:30 PDT 2023


Author: Yingwei Zheng
Date: 2023-09-25T01:48:26+08:00
New Revision: b7e9ef729a7902b816a1eff83cfda3a8a7982423

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

LOG: [InstCombine] Add conjugate part of pre-commit tests for PR57328. NFC.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/test/Transforms/InstCombine/ispow2.ll b/llvm/test/Transforms/InstCombine/ispow2.ll
index 356f23e1a01d3ff..740f79cd32b39e8 100644
--- a/llvm/test/Transforms/InstCombine/ispow2.ll
+++ b/llvm/test/Transforms/InstCombine/ispow2.ll
@@ -223,6 +223,36 @@ define i1 @is_pow2_non_zero_eq_1(i32 %x) {
   ret i1 %cmp
 }
 
+define i1 @is_pow2_non_zero_ugt_1(i32 %x) {
+; CHECK-LABEL: @is_pow2_non_zero_ugt_1(
+; CHECK-NEXT:    [[NOTZERO:%.*]] = icmp ne i32 [[X:%.*]], 0
+; CHECK-NEXT:    call void @llvm.assume(i1 [[NOTZERO]])
+; CHECK-NEXT:    [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X]]), !range [[RNG0]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ugt i32 [[T0]], 1
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %notzero = icmp ne i32 %x, 0
+  call void @llvm.assume(i1 %notzero)
+  %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)
+  %cmp = icmp ugt i32 %t0, 1
+  ret i1 %cmp
+}
+
+define i1 @is_pow2_non_zero_ne_1(i32 %x) {
+; CHECK-LABEL: @is_pow2_non_zero_ne_1(
+; CHECK-NEXT:    [[NOTZERO:%.*]] = icmp ne i32 [[X:%.*]], 0
+; CHECK-NEXT:    call void @llvm.assume(i1 [[NOTZERO]])
+; CHECK-NEXT:    [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X]]), !range [[RNG0]]
+; CHECK-NEXT:    [[CMP:%.*]] = icmp ne i32 [[T0]], 1
+; CHECK-NEXT:    ret i1 [[CMP]]
+;
+  %notzero = icmp ne i32 %x, 0
+  call void @llvm.assume(i1 %notzero)
+  %t0 = tail call i32 @llvm.ctpop.i32(i32 %x)
+  %cmp = icmp ne i32 %t0, 1
+  ret i1 %cmp
+}
+
 define i1 @is_pow2_ctpop_logical(i32 %x) {
 ; CHECK-LABEL: @is_pow2_ctpop_logical(
 ; CHECK-NEXT:    [[T0:%.*]] = tail call i32 @llvm.ctpop.i32(i32 [[X:%.*]]), !range [[RNG0]]


        


More information about the llvm-commits mailing list