mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-12-09 04:24:10 +00:00
[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
This commit is contained in:
parent
6af1a29943
commit
92dc649f34
187
test/Analysis/ConstantFolding/bitcount.ll
Normal file
187
test/Analysis/ConstantFolding/bitcount.ll
Normal file
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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
|
||||
}
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user