[llvm] b85de2c - [InstCombine] Add bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector tests
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 30 08:01:19 PDT 2020
Author: Simon Pilgrim
Date: 2020-09-30T16:01:08+01:00
New Revision: b85de2c69cf3d6fbc2ad3439a6224667a58f704c
URL: https://github.com/llvm/llvm-project/commit/b85de2c69cf3d6fbc2ad3439a6224667a58f704c
DIFF: https://github.com/llvm/llvm-project/commit/b85de2c69cf3d6fbc2ad3439a6224667a58f704c.diff
LOG: [InstCombine] Add bswap(trunc(bswap(x))) -> trunc(lshr(x, c)) vector tests
Add tests showing failure to correctly fold vector bswap(trunc(bswap(x))) intrinsic patterns
Added:
Modified:
llvm/test/Transforms/InstCombine/bswap-fold.ll
Removed:
################################################################################
diff --git a/llvm/test/Transforms/InstCombine/bswap-fold.ll b/llvm/test/Transforms/InstCombine/bswap-fold.ll
index 5e9c0923d6c5..c90b880f0ea7 100644
--- a/llvm/test/Transforms/InstCombine/bswap-fold.ll
+++ b/llvm/test/Transforms/InstCombine/bswap-fold.ll
@@ -37,6 +37,16 @@ define i16 @test7(i32 %A) {
ret i16 %D
}
+define <2 x i16> @test7_vector(<2 x i32> %A) {
+; CHECK-LABEL: @test7_vector(
+; CHECK-NEXT: ret <2 x i16> undef
+;
+ %B = tail call <2 x i32> @llvm.bswap.v2i32(<2 x i32> %A) nounwind
+ %C = trunc <2 x i32> %B to <2 x i16>
+ %D = tail call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %C) nounwind
+ ret <2 x i16> %D
+}
+
define i16 @test8(i64 %A) {
; CHECK-LABEL: @test8(
; CHECK-NEXT: [[TMP1:%.*]] = lshr i64 [[A:%.*]], 48
@@ -49,6 +59,16 @@ define i16 @test8(i64 %A) {
ret i16 %D
}
+define <2 x i16> @test8_vector(<2 x i64> %A) {
+; CHECK-LABEL: @test8_vector(
+; CHECK-NEXT: ret <2 x i16> undef
+;
+ %B = tail call <2 x i64> @llvm.bswap.v2i64(<2 x i64> %A) nounwind
+ %C = trunc <2 x i64> %B to <2 x i16>
+ %D = tail call <2 x i16> @llvm.bswap.v2i16(<2 x i16> %C) nounwind
+ ret <2 x i16> %D
+}
+
; Misc: Fold bswap(undef) to undef.
define i64 @foo() {
; CHECK-LABEL: @foo(
@@ -334,4 +354,6 @@ define i64 @bs_and64i_multiuse(i64 %a, i64 %b) #0 {
declare i16 @llvm.bswap.i16(i16)
declare i32 @llvm.bswap.i32(i32)
declare i64 @llvm.bswap.i64(i64)
+declare <2 x i16> @llvm.bswap.v2i16(<2 x i16>)
declare <2 x i32> @llvm.bswap.v2i32(<2 x i32>)
+declare <2 x i64> @llvm.bswap.v2i64(<2 x i64>)
More information about the llvm-commits
mailing list