diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-17 18:58:01 +0000 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2014-03-17 18:58:01 +0000 |
commit | 94bdb453a40e53e4318380b5a262ce3c324d10ce (patch) | |
tree | ba016c94f7b6741830f594bb9c5890e235c182bc /test/CodeGen | |
parent | 63d93faa9b2a8a1a38758f9ca9cff79bc0cac5fc (diff) | |
download | llvm-94bdb453a40e53e4318380b5a262ce3c324d10ce.tar.gz llvm-94bdb453a40e53e4318380b5a262ce3c324d10ce.tar.bz2 llvm-94bdb453a40e53e4318380b5a262ce3c324d10ce.tar.xz |
Make DAGCombiner work on vector bitshifts with constant splat vectors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/AArch64/neon-shl-ashr-lshr.ll | 6 | ||||
-rw-r--r-- | test/CodeGen/X86/avx2-vector-shifts.ll | 27 | ||||
-rw-r--r-- | test/CodeGen/X86/sse2-vector-shifts.ll | 152 |
3 files changed, 158 insertions, 27 deletions
diff --git a/test/CodeGen/AArch64/neon-shl-ashr-lshr.ll b/test/CodeGen/AArch64/neon-shl-ashr-lshr.ll index bd52fbde42..0b520d7ac8 100644 --- a/test/CodeGen/AArch64/neon-shl-ashr-lshr.ll +++ b/test/CodeGen/AArch64/neon-shl-ashr-lshr.ll @@ -186,14 +186,14 @@ define <2 x i64> @ashr.v2i64(<2 x i64> %a, <2 x i64> %b) { define <1 x i64> @shl.v1i64.0(<1 x i64> %a) { ; CHECK-LABEL: shl.v1i64.0: -; CHECK: shl d{{[0-9]+}}, d{{[0-9]+}}, #0 +; CHECK-NOT: shl d{{[0-9]+}}, d{{[0-9]+}}, #0 %c = shl <1 x i64> %a, zeroinitializer ret <1 x i64> %c } define <2 x i32> @shl.v2i32.0(<2 x i32> %a) { ; CHECK-LABEL: shl.v2i32.0: -; CHECK: shl v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #0 +; CHECK-NOT: shl v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #0 %c = shl <2 x i32> %a, zeroinitializer ret <2 x i32> %c } @@ -285,7 +285,7 @@ define <1 x i16> @shl.v1i16.imm(<1 x i16> %a) { define <1 x i32> @shl.v1i32.imm(<1 x i32> %a) { ; CHECK-LABEL: shl.v1i32.imm: -; CHECK: shl v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #0 +; CHECK-NOT: shl v{{[0-9]+}}.2s, v{{[0-9]+}}.2s, #0 %c = shl <1 x i32> %a, zeroinitializer ret <1 x i32> %c } diff --git a/test/CodeGen/X86/avx2-vector-shifts.ll b/test/CodeGen/X86/avx2-vector-shifts.ll index 4868e4b479..4ae2905ef2 100644 --- a/test/CodeGen/X86/avx2-vector-shifts.ll +++ b/test/CodeGen/X86/avx2-vector-shifts.ll @@ -9,7 +9,7 @@ entry: } ; CHECK-LABEL: test_sllw_1: -; CHECK: vpsllw $0, %ymm0, %ymm0 +; CHECK-NOT: vpsllw $0, %ymm0, %ymm0 ; CHECK: ret define <16 x i16> @test_sllw_2(<16 x i16> %InVec) { @@ -39,7 +39,7 @@ entry: } ; CHECK-LABEL: test_slld_1: -; CHECK: vpslld $0, %ymm0, %ymm0 +; CHECK-NOT: vpslld $0, %ymm0, %ymm0 ; CHECK: ret define <8 x i32> @test_slld_2(<8 x i32> %InVec) { @@ -69,7 +69,7 @@ entry: } ; CHECK-LABEL: test_sllq_1: -; CHECK: vpsllq $0, %ymm0, %ymm0 +; CHECK-NOT: vpsllq $0, %ymm0, %ymm0 ; CHECK: ret define <4 x i64> @test_sllq_2(<4 x i64> %InVec) { @@ -101,7 +101,7 @@ entry: } ; CHECK-LABEL: test_sraw_1: -; CHECK: vpsraw $0, %ymm0, %ymm0 +; CHECK-NOT: vpsraw $0, %ymm0, %ymm0 ; CHECK: ret define <16 x i16> @test_sraw_2(<16 x i16> %InVec) { @@ -131,7 +131,7 @@ entry: } ; CHECK-LABEL: test_srad_1: -; CHECK: vpsrad $0, %ymm0, %ymm0 +; CHECK-NOT: vpsrad $0, %ymm0, %ymm0 ; CHECK: ret define <8 x i32> @test_srad_2(<8 x i32> %InVec) { @@ -163,7 +163,7 @@ entry: } ; CHECK-LABEL: test_srlw_1: -; CHECK: vpsrlw $0, %ymm0, %ymm0 +; CHECK-NOT: vpsrlw $0, %ymm0, %ymm0 ; CHECK: ret define <16 x i16> @test_srlw_2(<16 x i16> %InVec) { @@ -193,7 +193,7 @@ entry: } ; CHECK-LABEL: test_srld_1: -; CHECK: vpsrld $0, %ymm0, %ymm0 +; CHECK-NOT: vpsrld $0, %ymm0, %ymm0 ; CHECK: ret define <8 x i32> @test_srld_2(<8 x i32> %InVec) { @@ -223,7 +223,7 @@ entry: } ; CHECK-LABEL: test_srlq_1: -; CHECK: vpsrlq $0, %ymm0, %ymm0 +; CHECK-NOT: vpsrlq $0, %ymm0, %ymm0 ; CHECK: ret define <4 x i64> @test_srlq_2(<4 x i64> %InVec) { @@ -245,3 +245,14 @@ entry: ; CHECK-LABEL: test_srlq_3: ; CHECK: vpsrlq $63, %ymm0, %ymm0 ; CHECK: ret + +; CHECK-LABEL: @srl_trunc_and_v4i64 +; CHECK: vpand +; CHECK-NEXT: vpsrlvd +; CHECK: ret +define <4 x i32> @srl_trunc_and_v4i64(<4 x i32> %x, <4 x i64> %y) nounwind { + %and = and <4 x i64> %y, <i64 8, i64 8, i64 8, i64 8> + %trunc = trunc <4 x i64> %and to <4 x i32> + %sra = lshr <4 x i32> %x, %trunc + ret <4 x i32> %sra +} diff --git a/test/CodeGen/X86/sse2-vector-shifts.ll b/test/CodeGen/X86/sse2-vector-shifts.ll index 47a01ff258..7c8d5e5788 100644 --- a/test/CodeGen/X86/sse2-vector-shifts.ll +++ b/test/CodeGen/X86/sse2-vector-shifts.ll @@ -9,8 +9,8 @@ entry: } ; CHECK-LABEL: test_sllw_1: -; CHECK: psllw $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psllw $0, %xmm0 +; CHECK: ret define <8 x i16> @test_sllw_2(<8 x i16> %InVec) { entry: @@ -39,8 +39,8 @@ entry: } ; CHECK-LABEL: test_slld_1: -; CHECK: pslld $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: pslld $0, %xmm0 +; CHECK: ret define <4 x i32> @test_slld_2(<4 x i32> %InVec) { entry: @@ -69,8 +69,8 @@ entry: } ; CHECK-LABEL: test_sllq_1: -; CHECK: psllq $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psllq $0, %xmm0 +; CHECK: ret define <2 x i64> @test_sllq_2(<2 x i64> %InVec) { entry: @@ -101,8 +101,8 @@ entry: } ; CHECK-LABEL: test_sraw_1: -; CHECK: psraw $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psraw $0, %xmm0 +; CHECK: ret define <8 x i16> @test_sraw_2(<8 x i16> %InVec) { entry: @@ -131,8 +131,8 @@ entry: } ; CHECK-LABEL: test_srad_1: -; CHECK: psrad $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psrad $0, %xmm0 +; CHECK: ret define <4 x i32> @test_srad_2(<4 x i32> %InVec) { entry: @@ -163,8 +163,8 @@ entry: } ; CHECK-LABEL: test_srlw_1: -; CHECK: psrlw $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psrlw $0, %xmm0 +; CHECK: ret define <8 x i16> @test_srlw_2(<8 x i16> %InVec) { entry: @@ -193,8 +193,8 @@ entry: } ; CHECK-LABEL: test_srld_1: -; CHECK: psrld $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psrld $0, %xmm0 +; CHECK: ret define <4 x i32> @test_srld_2(<4 x i32> %InVec) { entry: @@ -223,8 +223,8 @@ entry: } ; CHECK-LABEL: test_srlq_1: -; CHECK: psrlq $0, %xmm0 -; CHECK-NEXT: ret +; CHECK-NOT: psrlq $0, %xmm0 +; CHECK: ret define <2 x i64> @test_srlq_2(<2 x i64> %InVec) { entry: @@ -245,3 +245,123 @@ entry: ; CHECK-LABEL: test_srlq_3: ; CHECK: psrlq $63, %xmm0 ; CHECK-NEXT: ret + + +; CHECK-LABEL: sra_sra_v4i32: +; CHECK: psrad $6, %xmm0 +; CHECK-NEXT: retq +define <4 x i32> @sra_sra_v4i32(<4 x i32> %x) nounwind { + %sra0 = ashr <4 x i32> %x, <i32 2, i32 2, i32 2, i32 2> + %sra1 = ashr <4 x i32> %sra0, <i32 4, i32 4, i32 4, i32 4> + ret <4 x i32> %sra1 +} + +; CHECK-LABEL: @srl_srl_v4i32 +; CHECK: psrld $6, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @srl_srl_v4i32(<4 x i32> %x) nounwind { + %srl0 = lshr <4 x i32> %x, <i32 2, i32 2, i32 2, i32 2> + %srl1 = lshr <4 x i32> %srl0, <i32 4, i32 4, i32 4, i32 4> + ret <4 x i32> %srl1 +} + +; CHECK-LABEL: @srl_shl_v4i32 +; CHECK: andps +; CHECK-NEXT: retq +define <4 x i32> @srl_shl_v4i32(<4 x i32> %x) nounwind { + %srl0 = shl <4 x i32> %x, <i32 4, i32 4, i32 4, i32 4> + %srl1 = lshr <4 x i32> %srl0, <i32 4, i32 4, i32 4, i32 4> + ret <4 x i32> %srl1 +} + +; CHECK-LABEL: @srl_sra_31_v4i32 +; CHECK: psrld $31, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @srl_sra_31_v4i32(<4 x i32> %x, <4 x i32> %y) nounwind { + %sra = ashr <4 x i32> %x, %y + %srl1 = lshr <4 x i32> %sra, <i32 31, i32 31, i32 31, i32 31> + ret <4 x i32> %srl1 +} + +; CHECK-LABEL: @shl_shl_v4i32 +; CHECK: pslld $6, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @shl_shl_v4i32(<4 x i32> %x) nounwind { + %shl0 = shl <4 x i32> %x, <i32 2, i32 2, i32 2, i32 2> + %shl1 = shl <4 x i32> %shl0, <i32 4, i32 4, i32 4, i32 4> + ret <4 x i32> %shl1 +} + +; CHECK-LABEL: @shl_sra_v4i32 +; CHECK: andps +; CHECK-NEXT: ret +define <4 x i32> @shl_sra_v4i32(<4 x i32> %x) nounwind { + %shl0 = ashr <4 x i32> %x, <i32 4, i32 4, i32 4, i32 4> + %shl1 = shl <4 x i32> %shl0, <i32 4, i32 4, i32 4, i32 4> + ret <4 x i32> %shl1 +} + +; CHECK-LABEL: @shl_srl_v4i32 +; CHECK: pslld $3, %xmm0 +; CHECK-NEXT: pand +; CHECK-NEXT: ret +define <4 x i32> @shl_srl_v4i32(<4 x i32> %x) nounwind { + %shl0 = lshr <4 x i32> %x, <i32 2, i32 2, i32 2, i32 2> + %shl1 = shl <4 x i32> %shl0, <i32 5, i32 5, i32 5, i32 5> + ret <4 x i32> %shl1 +} + +; CHECK-LABEL: @shl_zext_srl_v4i32 +; CHECK: andps +; CHECK-NEXT: ret +define <4 x i32> @shl_zext_srl_v4i32(<4 x i16> %x) nounwind { + %srl = lshr <4 x i16> %x, <i16 2, i16 2, i16 2, i16 2> + %zext = zext <4 x i16> %srl to <4 x i32> + %shl = shl <4 x i32> %zext, <i32 2, i32 2, i32 2, i32 2> + ret <4 x i32> %shl +} + +; CHECK: @sra_trunc_srl_v4i32 +; CHECK: psrad $19, %xmm0 +; CHECK-NEXT: retq +define <4 x i16> @sra_trunc_srl_v4i32(<4 x i32> %x) nounwind { + %srl = lshr <4 x i32> %x, <i32 16, i32 16, i32 16, i32 16> + %trunc = trunc <4 x i32> %srl to <4 x i16> + %sra = ashr <4 x i16> %trunc, <i16 3, i16 3, i16 3, i16 3> + ret <4 x i16> %sra +} + +; CHECK-LABEL: @shl_zext_shl_v4i32 +; CHECK: pand +; CHECK-NEXT: pslld $19, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @shl_zext_shl_v4i32(<4 x i16> %x) nounwind { + %shl0 = shl <4 x i16> %x, <i16 2, i16 2, i16 2, i16 2> + %ext = zext <4 x i16> %shl0 to <4 x i32> + %shl1 = shl <4 x i32> %ext, <i32 17, i32 17, i32 17, i32 17> + ret <4 x i32> %shl1 +} + +; CHECK-LABEL: @sra_v4i32 +; CHECK: psrad $3, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @sra_v4i32(<4 x i32> %x) nounwind { + %sra = ashr <4 x i32> %x, <i32 3, i32 3, i32 3, i32 3> + ret <4 x i32> %sra +} + +; CHECK-LABEL: @srl_v4i32 +; CHECK: psrld $3, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @srl_v4i32(<4 x i32> %x) nounwind { + %sra = lshr <4 x i32> %x, <i32 3, i32 3, i32 3, i32 3> + ret <4 x i32> %sra +} + +; CHECK-LABEL: @shl_v4i32 +; CHECK: pslld $3, %xmm0 +; CHECK-NEXT: ret +define <4 x i32> @shl_v4i32(<4 x i32> %x) nounwind { + %sra = shl <4 x i32> %x, <i32 3, i32 3, i32 3, i32 3> + ret <4 x i32> %sra +} |