From d9c53710d55cc583f94e3cb439275b4fca99f50d Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Thu, 8 Dec 2016 10:17:25 +0000 Subject: [PATCH] [X86][SSE] Add vector test for (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2) detailed in D19325 llvm-svn: 289035 --- llvm/test/CodeGen/X86/combine-shl.ll | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/llvm/test/CodeGen/X86/combine-shl.ll b/llvm/test/CodeGen/X86/combine-shl.ll index 68c4ddf..88a68b5 100644 --- a/llvm/test/CodeGen/X86/combine-shl.ll +++ b/llvm/test/CodeGen/X86/combine-shl.ll @@ -543,6 +543,42 @@ define <4 x i32> @combine_vec_shl_add1(<4 x i32> %x) { ret <4 x i32> %2 } +; FIXME: fold (shl (or x, c1), c2) -> (or (shl x, c2), c1 << c2) +define <4 x i32> @combine_vec_shl_or0(<4 x i32> %x) { +; SSE-LABEL: combine_vec_shl_or0: +; SSE: # BB#0: +; SSE-NEXT: por {{.*}}(%rip), %xmm0 +; SSE-NEXT: pslld $2, %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: combine_vec_shl_or0: +; AVX: # BB#0: +; AVX-NEXT: vpbroadcastd {{.*}}(%rip), %xmm1 +; AVX-NEXT: vpor %xmm1, %xmm0, %xmm0 +; AVX-NEXT: vpslld $2, %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = or <4 x i32> %x, + %2 = shl <4 x i32> %1, + ret <4 x i32> %2 +} + +define <4 x i32> @combine_vec_shl_or1(<4 x i32> %x) { +; SSE-LABEL: combine_vec_shl_or1: +; SSE: # BB#0: +; SSE-NEXT: por {{.*}}(%rip), %xmm0 +; SSE-NEXT: pmulld {{.*}}(%rip), %xmm0 +; SSE-NEXT: retq +; +; AVX-LABEL: combine_vec_shl_or1: +; AVX: # BB#0: +; AVX-NEXT: vpor {{.*}}(%rip), %xmm0, %xmm0 +; AVX-NEXT: vpsllvd {{.*}}(%rip), %xmm0, %xmm0 +; AVX-NEXT: retq + %1 = or <4 x i32> %x, + %2 = shl <4 x i32> %1, + ret <4 x i32> %2 +} + ; fold (shl (mul x, c1), c2) -> (mul x, c1 << c2) define <4 x i32> @combine_vec_shl_mul0(<4 x i32> %x) { ; SSE-LABEL: combine_vec_shl_mul0: -- 2.7.4