diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-20 19:46:52 +0000 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2018-12-20 19:46:52 +0000 |
commit | f17421e595fe1becbc57fa873ec6278fd7fce188 (patch) | |
tree | 90548d2f61f52be80abc5228eaa326875b28734e | |
parent | 6d79e43208a5afd4e4dc100249f5f0cbf43e8571 (diff) | |
download | bcm5719-llvm-f17421e595fe1becbc57fa873ec6278fd7fce188.tar.gz bcm5719-llvm-f17421e595fe1becbc57fa873ec6278fd7fce188.zip |
[ConstantFolding] Consolidate and extend bitcount intrinsic tests; NFC
Move constant folding tests into ConstantFolding/bitcount.ll and drop
various tests in other places. Add coverage for undefs.
llvm-svn: 349806
-rw-r--r-- | llvm/test/Analysis/ConstantFolding/bitcount.ll | 187 | ||||
-rw-r--r-- | llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll | 8 | ||||
-rw-r--r-- | llvm/test/Transforms/InstCombine/bitcount.ll | 19 | ||||
-rw-r--r-- | llvm/test/Transforms/InstSimplify/call.ll | 30 |
4 files changed, 187 insertions, 57 deletions
diff --git a/llvm/test/Analysis/ConstantFolding/bitcount.ll b/llvm/test/Analysis/ConstantFolding/bitcount.ll new file mode 100644 index 00000000000..5ef9b2e8995 --- /dev/null +++ b/llvm/test/Analysis/ConstantFolding/bitcount.ll @@ -0,0 +1,187 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -constprop -S | FileCheck %s + +declare i31 @llvm.ctpop.i31(i31 %val) +declare i32 @llvm.cttz.i32(i32 %val, i1) +declare i33 @llvm.ctlz.i33(i33 %val, i1) +declare <2 x i31> @llvm.ctpop.v2i31(<2 x i31> %val) +declare <2 x i32> @llvm.cttz.v2i32(<2 x i32> %val, i1) +declare <2 x i33> @llvm.ctlz.v2i33(<2 x i33> %val, i1) + +define i31 @ctpop_const() { +; CHECK-LABEL: @ctpop_const( +; CHECK-NEXT: ret i31 12 +; + %x = call i31 @llvm.ctpop.i31(i31 12415124) + ret i31 %x +} + +define i32 @cttz_const() { +; CHECK-LABEL: @cttz_const( +; CHECK-NEXT: ret i32 1 +; + %x = call i32 @llvm.cttz.i32(i32 87359874, i1 true) + ret i32 %x +} + +define i33 @ctlz_const() { +; CHECK-LABEL: @ctlz_const( +; CHECK-NEXT: ret i33 6 +; + %x = call i33 @llvm.ctlz.i33(i33 87359874, i1 true) + ret i33 %x +} + +define i31 @ctpop_zero() { +; CHECK-LABEL: @ctpop_zero( +; CHECK-NEXT: ret i31 0 +; + %x = call i31 @llvm.ctpop.i31(i31 0) + ret i31 %x +} + +define i32 @cttz_zero_defined() { +; CHECK-LABEL: @cttz_zero_defined( +; CHECK-NEXT: ret i32 32 +; + %x = call i32 @llvm.cttz.i32(i32 0, i1 false) + ret i32 %x +} + +define i32 @cttz_zero_undefined() { +; CHECK-LABEL: @cttz_zero_undefined( +; CHECK-NEXT: ret i32 undef +; + %x = call i32 @llvm.cttz.i32(i32 0, i1 true) + ret i32 %x +} + +define i33 @ctlz_zero_defined() { +; CHECK-LABEL: @ctlz_zero_defined( +; CHECK-NEXT: ret i33 33 +; + %x = call i33 @llvm.ctlz.i33(i33 0, i1 false) + ret i33 %x +} + +define i33 @ctlz_zero_undefined() { +; CHECK-LABEL: @ctlz_zero_undefined( +; CHECK-NEXT: ret i33 undef +; + %x = call i33 @llvm.ctlz.i33(i33 0, i1 true) + ret i33 %x +} + +define i31 @ctpop_undef() { +; CHECK-LABEL: @ctpop_undef( +; CHECK-NEXT: [[X:%.*]] = call i31 @llvm.ctpop.i31(i31 undef) +; CHECK-NEXT: ret i31 [[X]] +; + %x = call i31 @llvm.ctpop.i31(i31 undef) + ret i31 %x +} + +define i32 @cttz_undef_defined() { +; CHECK-LABEL: @cttz_undef_defined( +; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.cttz.i32(i32 undef, i1 false) +; CHECK-NEXT: ret i32 [[X]] +; + %x = call i32 @llvm.cttz.i32(i32 undef, i1 false) + ret i32 %x +} + +define i32 @cttz_undef_undefined() { +; CHECK-LABEL: @cttz_undef_undefined( +; CHECK-NEXT: [[X:%.*]] = call i32 @llvm.cttz.i32(i32 undef, i1 true) +; CHECK-NEXT: ret i32 [[X]] +; + %x = call i32 @llvm.cttz.i32(i32 undef, i1 true) + ret i32 %x +} + +define i33 @ctlz_undef_defined() { +; CHECK-LABEL: @ctlz_undef_defined( +; CHECK-NEXT: [[X:%.*]] = call i33 @llvm.ctlz.i33(i33 undef, i1 false) +; CHECK-NEXT: ret i33 [[X]] +; + %x = call i33 @llvm.ctlz.i33(i33 undef, i1 false) + ret i33 %x +} + +define i33 @ctlz_undef_undefined() { +; CHECK-LABEL: @ctlz_undef_undefined( +; CHECK-NEXT: [[X:%.*]] = call i33 @llvm.ctlz.i33(i33 undef, i1 true) +; CHECK-NEXT: ret i33 [[X]] +; + %x = call i33 @llvm.ctlz.i33(i33 undef, i1 true) + ret i33 %x +} + +define <2 x i31> @ctpop_vector() { +; CHECK-LABEL: @ctpop_vector( +; CHECK-NEXT: ret <2 x i31> <i31 8, i31 1> +; + %x = call <2 x i31> @llvm.ctpop.v2i31(<2 x i31> <i31 255, i31 16>) + ret <2 x i31> %x +} + +define <2 x i31> @ctpop_vector_undef() { +; CHECK-LABEL: @ctpop_vector_undef( +; CHECK-NEXT: [[X:%.*]] = call <2 x i31> @llvm.ctpop.v2i31(<2 x i31> <i31 0, i31 undef>) +; CHECK-NEXT: ret <2 x i31> [[X]] +; + %x = call <2 x i31> @llvm.ctpop.v2i31(<2 x i31> <i31 0, i31 undef>) + ret <2 x i31> %x +} + +define <2 x i32> @cttz_vector() { +; CHECK-LABEL: @cttz_vector( +; CHECK-NEXT: ret <2 x i32> <i32 0, i32 4> +; + %x = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> <i32 255, i32 16>, i1 true) + ret <2 x i32> %x +} + +define <2 x i32> @cttz_vector_undef_defined() { +; CHECK-LABEL: @cttz_vector_undef_defined( +; CHECK-NEXT: [[X:%.*]] = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> <i32 0, i32 undef>, i1 false) +; CHECK-NEXT: ret <2 x i32> [[X]] +; + %x = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> <i32 0, i32 undef>, i1 false) + ret <2 x i32> %x +} + +define <2 x i32> @cttz_vector_undef_undefined() { +; CHECK-LABEL: @cttz_vector_undef_undefined( +; CHECK-NEXT: [[X:%.*]] = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> <i32 0, i32 undef>, i1 true) +; CHECK-NEXT: ret <2 x i32> [[X]] +; + %x = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> <i32 0, i32 undef>, i1 true) + ret <2 x i32> %x +} + +define <2 x i33> @ctlz_vector() { +; CHECK-LABEL: @ctlz_vector( +; CHECK-NEXT: ret <2 x i33> <i33 25, i33 28> +; + %x = call <2 x i33> @llvm.ctlz.v2i33(<2 x i33> <i33 255, i33 16>, i1 true) + ret <2 x i33> %x +} + +define <2 x i33> @ctlz_vector_undef_defined() { +; CHECK-LABEL: @ctlz_vector_undef_defined( +; CHECK-NEXT: [[X:%.*]] = call <2 x i33> @llvm.ctlz.v2i33(<2 x i33> <i33 0, i33 undef>, i1 false) +; CHECK-NEXT: ret <2 x i33> [[X]] +; + %x = call <2 x i33> @llvm.ctlz.v2i33(<2 x i33> <i33 0, i33 undef>, i1 false) + ret <2 x i33> %x +} + +define <2 x i33> @ctlz_vector_undef_undefined() { +; CHECK-LABEL: @ctlz_vector_undef_undefined( +; CHECK-NEXT: [[X:%.*]] = call <2 x i33> @llvm.ctlz.v2i33(<2 x i33> <i33 0, i33 undef>, i1 true) +; CHECK-NEXT: ret <2 x i33> [[X]] +; + %x = call <2 x i33> @llvm.ctlz.v2i33(<2 x i33> <i33 0, i33 undef>, i1 true) + ret <2 x i33> %x +} diff --git a/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll b/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll deleted file mode 100644 index c5ee70c2ff1..00000000000 --- a/llvm/test/Transforms/ConstProp/2007-11-23-cttz.ll +++ /dev/null @@ -1,8 +0,0 @@ -; RUN: opt < %s -constprop -S | grep "ret i13 13" -; PR1816 -declare i13 @llvm.cttz.i13(i13, i1) - -define i13 @test() { - %X = call i13 @llvm.cttz.i13(i13 0, i1 false) - ret i13 %X -} diff --git a/llvm/test/Transforms/InstCombine/bitcount.ll b/llvm/test/Transforms/InstCombine/bitcount.ll deleted file mode 100644 index 318ca7339f1..00000000000 --- a/llvm/test/Transforms/InstCombine/bitcount.ll +++ /dev/null @@ -1,19 +0,0 @@ -; Tests to make sure bit counts of constants are folded -; RUN: opt < %s -instcombine -S | grep "ret i32 19" -; RUN: opt < %s -instcombine -S | \ -; RUN: grep -v declare | not grep llvm.ct - -declare i31 @llvm.ctpop.i31(i31 %val) -declare i32 @llvm.cttz.i32(i32 %val, i1) -declare i33 @llvm.ctlz.i33(i33 %val, i1) - -define i32 @test(i32 %A) { - %c1 = call i31 @llvm.ctpop.i31(i31 12415124) - %c2 = call i32 @llvm.cttz.i32(i32 87359874, i1 true) - %c3 = call i33 @llvm.ctlz.i33(i33 87359874, i1 true) - %t1 = zext i31 %c1 to i32 - %t3 = trunc i33 %c3 to i32 - %r1 = add i32 %t1, %c2 - %r2 = add i32 %r1, %t3 - ret i32 %r2 -} diff --git a/llvm/test/Transforms/InstSimplify/call.ll b/llvm/test/Transforms/InstSimplify/call.ll index b3a2f96870e..9d63d375afb 100644 --- a/llvm/test/Transforms/InstSimplify/call.ll +++ b/llvm/test/Transforms/InstSimplify/call.ll @@ -189,36 +189,6 @@ define {i8, i1} @test_smul4(i8 %V) { ret {i8, i1} %x } -declare i256 @llvm.cttz.i256(i256 %src, i1 %is_zero_undef) - -define i256 @test_cttz() { -; CHECK-LABEL: @test_cttz( -; CHECK-NEXT: ret i256 1 -; - %x = call i256 @llvm.cttz.i256(i256 10, i1 false) - ret i256 %x -} - -declare <2 x i256> @llvm.cttz.v2i256(<2 x i256> %src, i1 %is_zero_undef) - -define <2 x i256> @test_cttz_vec() { -; CHECK-LABEL: @test_cttz_vec( -; CHECK-NEXT: ret <2 x i256> <i256 1, i256 1> -; - %x = call <2 x i256> @llvm.cttz.v2i256(<2 x i256> <i256 10, i256 10>, i1 false) - ret <2 x i256> %x -} - -declare i256 @llvm.ctpop.i256(i256 %src) - -define i256 @test_ctpop() { -; CHECK-LABEL: @test_ctpop( -; CHECK-NEXT: ret i256 2 -; - %x = call i256 @llvm.ctpop.i256(i256 10) - ret i256 %x -} - ; Test a non-intrinsic that we know about as a library call. declare float @fabs(float %x) |