[InstCombine] add tests for missing vector folds

llvm-svn: 284245
This commit is contained in:
Sanjay Patel 2016-10-14 15:55:34 +00:00
parent a3bc38b36d
commit ecd0da2619
2 changed files with 33 additions and 0 deletions

View File

@ -12,6 +12,17 @@ define i32 @test1(i32 %x) {
ret i32 %sub
}
define <2 x i32> @test1vec(<2 x i32> %x) {
; CHECK-LABEL: @test1vec(
; CHECK-NEXT: [[AND:%.*]] = and <2 x i32> %x, <i32 31, i32 31>
; CHECK-NEXT: [[SUB:%.*]] = sub nsw <2 x i32> <i32 63, i32 63>, [[AND]]
; CHECK-NEXT: ret <2 x i32> [[SUB]]
;
%and = and <2 x i32> %x, <i32 31, i32 31>
%sub = sub <2 x i32> <i32 63, i32 63>, %and
ret <2 x i32> %sub
}
declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
define i32 @test2(i32 %x) nounwind {

View File

@ -152,6 +152,28 @@ define i32 @test13(i32 %A) {
ret i32 %C
}
define <2 x i32> @test12vec(<2 x i32> %A) {
; CHECK-LABEL: @test12vec(
; CHECK-NEXT: [[B:%.*]] = ashr <2 x i32> %A, <i32 31, i32 31>
; CHECK-NEXT: [[C:%.*]] = sub nsw <2 x i32> zeroinitializer, [[B]]
; CHECK-NEXT: ret <2 x i32> [[C]]
;
%B = ashr <2 x i32> %A, <i32 31, i32 31>
%C = sub <2 x i32> zeroinitializer, %B
ret <2 x i32> %C
}
define <2 x i32> @test13vec(<2 x i32> %A) {
; CHECK-LABEL: @test13vec(
; CHECK-NEXT: [[B:%.*]] = lshr <2 x i32> %A, <i32 31, i32 31>
; CHECK-NEXT: [[C:%.*]] = sub nsw <2 x i32> zeroinitializer, [[B]]
; CHECK-NEXT: ret <2 x i32> [[C]]
;
%B = lshr <2 x i32> %A, <i32 31, i32 31>
%C = sub <2 x i32> zeroinitializer, %B
ret <2 x i32> %C
}
define i32 @test15(i32 %A, i32 %B) {
; CHECK-LABEL: @test15(
; CHECK-NEXT: [[C:%.*]] = sub i32 0, %A