From: Simon Pilgrim Date: Fri, 2 Oct 2020 17:04:56 +0000 (+0100) Subject: [InstCombine] Add trunc(bswap(trunc/zext(x))) vector tests X-Git-Tag: llvmorg-13-init~10272 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d0dd7cadbd1f8fd57ac09dc9bb9c853ff0329988;p=platform%2Fupstream%2Fllvm.git [InstCombine] Add trunc(bswap(trunc/zext(x))) vector tests --- diff --git a/llvm/test/Transforms/InstCombine/bswap.ll b/llvm/test/Transforms/InstCombine/bswap.ll index af9350d..d6f0792 100644 --- a/llvm/test/Transforms/InstCombine/bswap.ll +++ b/llvm/test/Transforms/InstCombine/bswap.ll @@ -379,6 +379,24 @@ define i16 @test10(i32 %a) { ret i16 %conv } +define <2 x i16> @test10_vector(<2 x i32> %a) { +; CHECK-LABEL: @test10_vector( +; CHECK-NEXT: [[SHR1:%.*]] = lshr <2 x i32> [[A:%.*]], +; CHECK-NEXT: [[AND1:%.*]] = and <2 x i32> [[SHR1]], +; CHECK-NEXT: [[AND2:%.*]] = shl <2 x i32> [[A]], +; CHECK-NEXT: [[OR:%.*]] = or <2 x i32> [[AND1]], [[AND2]] +; CHECK-NEXT: [[CONV:%.*]] = trunc <2 x i32> [[OR]] to <2 x i16> +; CHECK-NEXT: ret <2 x i16> [[CONV]] +; + %shr1 = lshr <2 x i32> %a, + %and1 = and <2 x i32> %shr1, + %and2 = shl <2 x i32> %a, + %shl1 = and <2 x i32> %and2, + %or = or <2 x i32> %and1, %shl1 + %conv = trunc <2 x i32> %or to <2 x i16> + ret <2 x i16> %conv +} + define i64 @PR39793_bswap_u64_as_u32(i64 %0) { ; CHECK-LABEL: @PR39793_bswap_u64_as_u32( ; CHECK-NEXT: [[TRUNC:%.*]] = trunc i64 [[TMP0:%.*]] to i32 @@ -437,6 +455,23 @@ define i64 @PR39793_bswap_u64_as_u16(i64 %0) { ret i64 %6 } +define <2 x i64> @PR39793_bswap_u64_as_u16_vector(<2 x i64> %0) { +; CHECK-LABEL: @PR39793_bswap_u64_as_u16_vector( +; CHECK-NEXT: [[TMP2:%.*]] = lshr <2 x i64> [[TMP0:%.*]], +; CHECK-NEXT: [[TMP3:%.*]] = and <2 x i64> [[TMP2]], +; CHECK-NEXT: [[TMP4:%.*]] = shl <2 x i64> [[TMP0]], +; CHECK-NEXT: [[TMP5:%.*]] = and <2 x i64> [[TMP4]], +; CHECK-NEXT: [[TMP6:%.*]] = or <2 x i64> [[TMP3]], [[TMP5]] +; CHECK-NEXT: ret <2 x i64> [[TMP6]] +; + %2 = lshr <2 x i64> %0, + %3 = and <2 x i64> %2, + %4 = shl <2 x i64> %0, + %5 = and <2 x i64> %4, + %6 = or <2 x i64> %3, %5 + ret <2 x i64> %6 +} + define i8 @PR39793_bswap_u64_as_u16_trunc(i64 %0) { ; CHECK-LABEL: @PR39793_bswap_u64_as_u16_trunc( ; CHECK-NEXT: [[REV1:%.*]] = lshr i64 [[TMP0:%.*]], 8