mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
[InstCombine] add tests to document bitcast + bitwise-logic behavior; NFC
The solution for PR26702 ( https://bugs.llvm.org/show_bug.cgi?id=26702 ) added a canonicalization rule, but the minimal regression tests don't demonstrate how that rule interacts with other folds. llvm-svn: 303750
This commit is contained in:
parent
da6888ed6b
commit
733d481cb3
@ -70,6 +70,51 @@ define <2 x i32> @or_bitcast_int_to_vec(i64 %a) {
|
||||
ret <2 x i32> %t2
|
||||
}
|
||||
|
||||
; PR26702 - https://bugs.llvm.org//show_bug.cgi?id=26702
|
||||
; Bitcast is canonicalized below logic, so we can see the not-not pattern.
|
||||
|
||||
define <2 x i64> @is_negative(<4 x i32> %x) {
|
||||
; CHECK-LABEL: @is_negative(
|
||||
; CHECK-NEXT: [[LOBIT:%.*]] = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
|
||||
; CHECK-NEXT: [[NOTNOT:%.*]] = bitcast <4 x i32> [[LOBIT]] to <2 x i64>
|
||||
; CHECK-NEXT: ret <2 x i64> [[NOTNOT]]
|
||||
;
|
||||
%lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
|
||||
%not = xor <4 x i32> %lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
|
||||
%bc = bitcast <4 x i32> %not to <2 x i64>
|
||||
%notnot = xor <2 x i64> %bc, <i64 -1, i64 -1>
|
||||
ret <2 x i64> %notnot
|
||||
}
|
||||
|
||||
; This variation has an extra bitcast at the end. This means that the 2nd xor
|
||||
; can be done in <4 x i32> to eliminate a bitcast regardless of canonicalizaion.
|
||||
|
||||
define <4 x i32> @is_negative_bonus_bitcast(<4 x i32> %x) {
|
||||
; CHECK-LABEL: @is_negative_bonus_bitcast(
|
||||
; CHECK-NEXT: [[LOBIT:%.*]] = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
|
||||
; CHECK-NEXT: ret <4 x i32> [[LOBIT]]
|
||||
;
|
||||
%lobit = ashr <4 x i32> %x, <i32 31, i32 31, i32 31, i32 31>
|
||||
%not = xor <4 x i32> %lobit, <i32 -1, i32 -1, i32 -1, i32 -1>
|
||||
%bc = bitcast <4 x i32> %not to <2 x i64>
|
||||
%notnot = xor <2 x i64> %bc, <i64 -1, i64 -1>
|
||||
%bc2 = bitcast <2 x i64> %notnot to <4 x i32>
|
||||
ret <4 x i32> %bc2
|
||||
}
|
||||
|
||||
; Negative test: bitcasts are canonicalized below bitwise logic. No changes here.
|
||||
|
||||
define <2 x i8> @canonicalize_bitcast_logic_with_constant(<4 x i4> %x) {
|
||||
; CHECK-LABEL: @canonicalize_bitcast_logic_with_constant(
|
||||
; CHECK-NEXT: [[A:%.*]] = and <4 x i4> %x, <i4 0, i4 -8, i4 0, i4 -8>
|
||||
; CHECK-NEXT: [[B:%.*]] = bitcast <4 x i4> [[A]] to <2 x i8>
|
||||
; CHECK-NEXT: ret <2 x i8> [[B]]
|
||||
;
|
||||
%a = and <4 x i4> %x, <i4 0, i4 8, i4 0, i4 8>
|
||||
%b = bitcast <4 x i4> %a to <2 x i8>
|
||||
ret <2 x i8> %b
|
||||
}
|
||||
|
||||
; PR27925 - https://llvm.org/bugs/show_bug.cgi?id=27925
|
||||
|
||||
define <4 x i32> @bitcasts_and_bitcast(<4 x i32> %a, <8 x i16> %b) {
|
||||
|
Loading…
Reference in New Issue
Block a user