forked from OSchip/llvm-project
[InstCombine] add more tests for shuffle with different binops; NFC
llvm-svn: 335756
This commit is contained in:
parent
3209b28aa9
commit
7e45aebe55
|
@ -296,3 +296,39 @@ define <4 x i32> @shl_mul_not_constant_shift_amount(<4 x i32> %v0) {
|
|||
ret <4 x i32> %t3
|
||||
}
|
||||
|
||||
; Or with constant can be converted to add to enable the fold.
|
||||
; The 'shl' is here to allow analysis to determine that the 'or' can be transformed to 'add'.
|
||||
; TODO: The 'or' constant is limited to a splat.
|
||||
|
||||
define <4 x i32> @add_or(<4 x i32> %v) {
|
||||
; CHECK-LABEL: @add_or(
|
||||
; CHECK-NEXT: [[V0:%.*]] = shl <4 x i32> [[V:%.*]], <i32 5, i32 5, i32 5, i32 5>
|
||||
; CHECK-NEXT: [[T1:%.*]] = add <4 x i32> [[V0]], <i32 undef, i32 undef, i32 65536, i32 65537>
|
||||
; CHECK-NEXT: [[T2:%.*]] = or <4 x i32> [[V0]], <i32 31, i32 31, i32 undef, i32 undef>
|
||||
; CHECK-NEXT: [[T3:%.*]] = shufflevector <4 x i32> [[T1]], <4 x i32> [[T2]], <4 x i32> <i32 4, i32 5, i32 2, i32 3>
|
||||
; CHECK-NEXT: ret <4 x i32> [[T3]]
|
||||
;
|
||||
%v0 = shl <4 x i32> %v, <i32 5, i32 5, i32 5, i32 5> ; clear the bottom bits
|
||||
%t1 = add <4 x i32> %v0, <i32 65534, i32 65535, i32 65536, i32 65537> ; this can't be converted to 'or'
|
||||
%t2 = or <4 x i32> %v0, <i32 31, i32 31, i32 31, i32 31> ; set the bottom bits
|
||||
%t3 = shufflevector <4 x i32> %t1, <4 x i32> %t2, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
|
||||
ret <4 x i32> %t3
|
||||
}
|
||||
|
||||
; Try with 'or' as operand 0 of the shuffle.
|
||||
|
||||
define <4 x i8> @or_add(<4 x i8> %v) {
|
||||
; CHECK-LABEL: @or_add(
|
||||
; CHECK-NEXT: [[V0:%.*]] = lshr <4 x i8> [[V:%.*]], <i8 3, i8 3, i8 3, i8 3>
|
||||
; CHECK-NEXT: [[T1:%.*]] = or <4 x i8> [[V0]], <i8 undef, i8 undef, i8 -64, i8 -64>
|
||||
; CHECK-NEXT: [[T2:%.*]] = add nuw nsw <4 x i8> [[V0]], <i8 1, i8 2, i8 undef, i8 undef>
|
||||
; CHECK-NEXT: [[T3:%.*]] = shufflevector <4 x i8> [[T1]], <4 x i8> [[T2]], <4 x i32> <i32 4, i32 5, i32 2, i32 3>
|
||||
; CHECK-NEXT: ret <4 x i8> [[T3]]
|
||||
;
|
||||
%v0 = lshr <4 x i8> %v, <i8 3, i8 3, i8 3, i8 3> ; clear the top bits
|
||||
%t1 = or <4 x i8> %v0, <i8 192, i8 192, i8 192, i8 192> ; set some top bits
|
||||
%t2 = add nsw nuw <4 x i8> %v0, <i8 1, i8 2, i8 3, i8 4> ; this can't be converted to 'or'
|
||||
%t3 = shufflevector <4 x i8> %t1, <4 x i8> %t2, <4 x i32> <i32 4, i32 5, i32 2, i32 3>
|
||||
ret <4 x i8> %t3
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue