From 253ee85f344e5f62d70e7b7bc796bd7bd5da3330 Mon Sep 17 00:00:00 2001 From: Yingwei Zheng Date: Thu, 5 Oct 2023 20:30:23 +0800 Subject: [PATCH] [CVP] Add pre-commit cttz/ctpop tests. NFC. --- .../CorrelatedValuePropagation/range.ll | 94 +++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll index 7e89f864c8110e..6b4f8daaaeead3 100644 --- a/llvm/test/Transforms/CorrelatedValuePropagation/range.ll +++ b/llvm/test/Transforms/CorrelatedValuePropagation/range.ll @@ -1010,6 +1010,100 @@ else: ret i1 %res2 } +define i1 @cttz_fold(i16 %x) { +; CHECK-LABEL: @cttz_fold( +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256 +; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]] +; CHECK: if: +; CHECK-NEXT: [[CTTZ:%.*]] = call i16 @llvm.cttz.i16(i16 [[X]], i1 true) +; CHECK-NEXT: [[RES:%.*]] = icmp uge i16 [[CTTZ]], 8 +; CHECK-NEXT: ret i1 [[RES]] +; CHECK: else: +; CHECK-NEXT: ret i1 false +; + %cmp = icmp ult i16 %x, 256 + br i1 %cmp, label %if, label %else + +if: + %cttz = call i16 @llvm.cttz.i16(i16 %x, i1 true) + %res = icmp uge i16 %cttz, 8 + ret i1 %res + +else: + ret i1 false +} + +define i1 @cttz_nofold(i16 %x) { +; CHECK-LABEL: @cttz_nofold( +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256 +; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]] +; CHECK: if: +; CHECK-NEXT: [[CTTZ:%.*]] = call i16 @llvm.cttz.i16(i16 [[X]], i1 true) +; CHECK-NEXT: [[RES:%.*]] = icmp uge i16 [[CTTZ]], 9 +; CHECK-NEXT: ret i1 [[RES]] +; CHECK: else: +; CHECK-NEXT: ret i1 false +; + %cmp = icmp ult i16 %x, 256 + br i1 %cmp, label %if, label %else + +if: + %cttz = call i16 @llvm.cttz.i16(i16 %x, i1 true) + %res = icmp uge i16 %cttz, 9 + ret i1 %res + +else: + ret i1 false +} + +define i1 @ctpop_fold(i16 %x) { +; CHECK-LABEL: @ctpop_fold( +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256 +; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]] +; CHECK: if: +; CHECK-NEXT: [[CTPOP:%.*]] = call i16 @llvm.ctpop.i16(i16 [[X]]) +; CHECK-NEXT: [[RES:%.*]] = icmp ule i16 [[CTPOP]], 8 +; CHECK-NEXT: ret i1 [[RES]] +; CHECK: else: +; CHECK-NEXT: ret i1 true +; + %cmp = icmp ult i16 %x, 256 + br i1 %cmp, label %if, label %else + +if: + %ctpop = call i16 @llvm.ctpop.i16(i16 %x) + %res = icmp ule i16 %ctpop, 8 + ret i1 %res + +else: + ret i1 true +} + +define i1 @ctpop_nofold(i16 %x) { +; CHECK-LABEL: @ctpop_nofold( +; CHECK-NEXT: [[CMP:%.*]] = icmp ult i16 [[X:%.*]], 256 +; CHECK-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[ELSE:%.*]] +; CHECK: if: +; CHECK-NEXT: [[CTPOP:%.*]] = call i16 @llvm.ctpop.i16(i16 [[X]]) +; CHECK-NEXT: [[RES:%.*]] = icmp ule i16 [[CTPOP]], 7 +; CHECK-NEXT: ret i1 [[RES]] +; CHECK: else: +; CHECK-NEXT: ret i1 true +; + %cmp = icmp ult i16 %x, 256 + br i1 %cmp, label %if, label %else + +if: + %ctpop = call i16 @llvm.ctpop.i16(i16 %x) + %res = icmp ule i16 %ctpop, 7 + ret i1 %res + +else: + ret i1 true +} + declare i16 @llvm.ctlz.i16(i16, i1) +declare i16 @llvm.cttz.i16(i16, i1) +declare i16 @llvm.ctpop.i16(i16) declare i16 @llvm.abs.i16(i16, i1) declare void @llvm.assume(i1)