From 57a0b4edd76a2a10d1d85332e538661ee8ad2459 Mon Sep 17 00:00:00 2001 From: Sanjay Patel Date: Sat, 25 Aug 2018 14:37:08 +0000 Subject: [PATCH] [InstCombine] add tests for shuffle+binop transform; NFC llvm-svn: 340683 --- llvm/test/Transforms/InstCombine/vec_shuffle.ll | 52 +++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/llvm/test/Transforms/InstCombine/vec_shuffle.ll b/llvm/test/Transforms/InstCombine/vec_shuffle.ll index d1a4288..17aad93 100644 --- a/llvm/test/Transforms/InstCombine/vec_shuffle.ll +++ b/llvm/test/Transforms/InstCombine/vec_shuffle.ll @@ -474,6 +474,58 @@ define <2 x float> @fmul_const_invalid_constant(<2 x float> %v) { ret <2 x float> %r } +; TODO: Reduce the width of the binop by moving it ahead of a shuffle. + +define <4 x i8> @widening_shuffle_add_1(<2 x i8> %x) { +; CHECK-LABEL: @widening_shuffle_add_1( +; CHECK-NEXT: [[WIDEX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = add <4 x i8> [[WIDEX]], +; CHECK-NEXT: ret <4 x i8> [[R]] +; + %widex = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> + %r = add <4 x i8> %widex, + ret <4 x i8> %r +} + +; TODO: Reduce the width of the binop by moving it ahead of a shuffle. + +define <4 x i8> @widening_shuffle_add_2(<2 x i8> %x) { +; CHECK-LABEL: @widening_shuffle_add_2( +; CHECK-NEXT: [[WIDEX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = add <4 x i8> [[WIDEX]], +; CHECK-NEXT: ret <4 x i8> [[R]] +; + %widex = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> + %r = add <4 x i8> %widex, + ret <4 x i8> %r +} + +; Widening shuffles have the same mask/constant constraint as non-size-changing shuffles. + +define <4 x i8> @widening_shuffle_add_invalid_constant(<2 x i8> %x) { +; CHECK-LABEL: @widening_shuffle_add_invalid_constant( +; CHECK-NEXT: [[WIDEX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = add <4 x i8> [[WIDEX]], +; CHECK-NEXT: ret <4 x i8> [[R]] +; + %widex = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> + %r = add <4 x i8> %widex, + ret <4 x i8> %r +} + +; And widening shuffles have an additional constraint - they must not extend with anything but undefs. + +define <4 x i8> @widening_shuffle_add_invalid_mask(<2 x i8> %x) { +; CHECK-LABEL: @widening_shuffle_add_invalid_mask( +; CHECK-NEXT: [[WIDEX:%.*]] = shufflevector <2 x i8> [[X:%.*]], <2 x i8> undef, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = add <4 x i8> [[WIDEX]], +; CHECK-NEXT: ret <4 x i8> [[R]] +; + %widex = shufflevector <2 x i8> %x, <2 x i8> undef, <4 x i32> + %r = add <4 x i8> %widex, + ret <4 x i8> %r +} + define <4 x i32> @shuffle_17add2(<4 x i32> %v) { ; CHECK-LABEL: @shuffle_17add2( ; CHECK-NEXT: [[TMP1:%.*]] = shl <4 x i32> [[V:%.*]], -- 2.7.4