From 63d81311a2569226781dc00481feb91ea1423571 Mon Sep 17 00:00:00 2001 From: Ramkumar Ramachandra Date: Tue, 21 May 2024 08:06:34 +0100 Subject: [PATCH] VectorCombine: add tests written for InstSimplify (#92776) 2141907 (InstSimplify: increase shufflevector test coverage) was recently merged as a pre-commit test for some work that was misguided. It turns out that InstSimplify can never work on those tests, but the tests are useful nevertheless; move them to VectorCombine to support the development of VectorCombine::foldShuffleToIdentity. --- .../Transforms/InstSimplify/shufflevector.ll | 171 ------------------ .../AArch64/shuffletoidentity.ll | 166 ++++++++++++++++- 2 files changed, 162 insertions(+), 175 deletions(-) diff --git a/llvm/test/Transforms/InstSimplify/shufflevector.ll b/llvm/test/Transforms/InstSimplify/shufflevector.ll index 64087194b0d17f..20195051616050 100644 --- a/llvm/test/Transforms/InstSimplify/shufflevector.ll +++ b/llvm/test/Transforms/InstSimplify/shufflevector.ll @@ -337,174 +337,3 @@ define <4 x i32> @not_fold_identity2(<4 x i32> %x) { %revshuf = shufflevector <4 x i32> %shuf, <4 x i32> poison, <4 x i32> ret <4 x i32> %revshuf } - -define <4 x i64> @fold_lookthrough_cast(<4 x i32> %x) { -; CHECK-LABEL: @fold_lookthrough_cast( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ZEXT]], <4 x i64> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %zext = zext <4 x i32> %shuf to <4 x i64> - %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> - ret <4 x i64> %revshuf -} - -define <4 x i64> @not_fold_lookthrough_cast(<4 x i32> %x) { -; CHECK-LABEL: @not_fold_lookthrough_cast( -; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[X:%.*]] to <4 x i64> -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ZEXT]], <4 x i64> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] -; - %zext = zext <4 x i32> %x to <4 x i64> - %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> - ret <4 x i64> %revshuf -} - -define <4 x i64> @not_fold_lookthrough_cast2(<4 x i32> %x) { -; CHECK-LABEL: @not_fold_lookthrough_cast2( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> -; CHECK-NEXT: ret <4 x i64> [[ZEXT]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %zext = zext <4 x i32> %shuf to <4 x i64> - ret <4 x i64> %zext -} - -define i32 @not_fold_lookthrough_bitcast(<4 x i8> %x) { -; CHECK-LABEL: @not_fold_lookthrough_bitcast( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> -; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i8> [[SHUF]] to i32 -; CHECK-NEXT: ret i32 [[BITCAST]] -; - %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> - %bitcast = bitcast <4 x i8> %shuf to i32 - ret i32 %bitcast -} - -define <8 x i16> @not_fold_lookthrough_bitcast2(<4 x i32> %x, <8 x i16> %y) { -; CHECK-LABEL: @not_fold_lookthrough_bitcast2( -; CHECK-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[X:%.*]] to <8 x i16> -; CHECK-NEXT: [[OUT:%.*]] = shufflevector <8 x i16> [[Y:%.*]], <8 x i16> [[CAST]], <8 x i32> -; CHECK-NEXT: ret <8 x i16> [[OUT]] -; - %cast = bitcast <4 x i32> %x to <8 x i16> - %out = shufflevector <8 x i16> %y, <8 x i16> %cast, <8 x i32> - ret <8 x i16> %out -} - -define <4 x i32> @fold_lookthrough_binop_same_operands(<4 x i32> %x) { -; CHECK-LABEL: @fold_lookthrough_binop_same_operands( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i32> [[REVSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %add = add <4 x i32> %shuf, %shuf - %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> - ret <4 x i32> %revshuf -} - -define <4 x i32> @fold_lookthrough_binop_different_operands(<4 x i32> %x, <4 x i32> %y) { -; CHECK-LABEL: @fold_lookthrough_binop_different_operands( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[Y:%.*]] -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i32> [[REVSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %add = add <4 x i32> %shuf, %y - %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> - ret <4 x i32> %revshuf -} - -define <4 x i32> @fold_lookthrough_binop_multiuse(<4 x i32> %x) { -; CHECK-LABEL: @fold_lookthrough_binop_multiuse( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ADD2:%.*]] = add <4 x i32> [[SHUF]], [[REVSHUF]] -; CHECK-NEXT: ret <4 x i32> [[ADD2]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %add = add <4 x i32> %shuf, %shuf - %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> - %add2 = add <4 x i32> %shuf, %revshuf - ret <4 x i32> %add2 -} - -define <4 x i64> @fold_lookthrough_cast_chain(<4 x i16> %x) { -; CHECK-LABEL: @fold_lookthrough_cast_chain( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i16> [[X:%.*]], <4 x i16> poison, <4 x i32> -; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i16> [[SHUF]] to <4 x i32> -; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i32> [[ZEXT]] to <4 x i64> -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[SEXT]], <4 x i64> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] -; - %shuf = shufflevector <4 x i16> %x, <4 x i16> poison, <4 x i32> - %zext = zext <4 x i16> %shuf to <4 x i32> - %sext = sext <4 x i32> %zext to <4 x i64> - %revshuf = shufflevector <4 x i64> %sext, <4 x i64> poison, <4 x i32> - ret <4 x i64> %revshuf -} - -define <4 x i32> @fold_lookthrough_binop_chain(<4 x i32> %x) { -; CHECK-LABEL: @fold_lookthrough_binop_chain( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] -; CHECK-NEXT: [[ADD2:%.*]] = add <4 x i32> [[ADD]], [[ADD]] -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD2]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i32> [[REVSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %add = add <4 x i32> %shuf, %shuf - %add2 = add <4 x i32> %add, %add - %revshuf = shufflevector <4 x i32> %add2, <4 x i32> poison, <4 x i32> - ret <4 x i32> %revshuf -} - -define <4 x i64> @fold_lookthrough_cast_binop_chain(<4 x i32> %x) { -; CHECK-LABEL: @fold_lookthrough_cast_binop_chain( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> -; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> -; CHECK-NEXT: [[ADD:%.*]] = add <4 x i64> [[ZEXT]], [[ZEXT]] -; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ADD]], <4 x i64> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> - %zext = zext <4 x i32> %shuf to <4 x i64> - %add = add <4 x i64> %zext, %zext - %revshuf = shufflevector <4 x i64> %add, <4 x i64> poison, <4 x i32> - ret <4 x i64> %revshuf -} - -define <4 x i64> @not_fold_cast_mismatched_types(<4 x i32> %x) { -; CHECK-LABEL: @not_fold_cast_mismatched_types( -; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <2 x i32> -; CHECK-NEXT: [[ZEXT:%.*]] = zext <2 x i32> [[SHUF]] to <2 x i64> -; CHECK-NEXT: [[EXTSHUF:%.*]] = shufflevector <2 x i64> [[ZEXT]], <2 x i64> poison, <4 x i32> -; CHECK-NEXT: ret <4 x i64> [[EXTSHUF]] -; - %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <2 x i32> - %zext = zext <2 x i32> %shuf to <2 x i64> - %extshuf = shufflevector <2 x i64> %zext, <2 x i64> poison, <4 x i32> - ret <4 x i64> %extshuf -} - -define <4 x float> @not_fold_binop_mismatched_types(<4 x float> %x, <4 x float> %y) { -; CHECK-LABEL: @not_fold_binop_mismatched_types( -; CHECK-NEXT: [[SHUF_X:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <2 x i32> -; CHECK-NEXT: [[SHUF_Y:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> poison, <2 x i32> -; CHECK-NEXT: [[FADD:%.*]] = fadd fast <2 x float> [[SHUF_X]], [[SHUF_Y]] -; CHECK-NEXT: [[EXTSHUF:%.*]] = shufflevector <2 x float> [[FADD]], <2 x float> poison, <4 x i32> -; CHECK-NEXT: ret <4 x float> [[EXTSHUF]] -; - %shuf.x = shufflevector <4 x float> %x, <4 x float> poison, <2 x i32> - %shuf.y = shufflevector <4 x float> %y, <4 x float> poison, <2 x i32> - %fadd = fadd fast <2 x float> %shuf.x, %shuf.y - %extshuf = shufflevector <2 x float> %fadd, <2 x float> poison, <4 x i32> - ret <4 x float> %extshuf -} diff --git a/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll b/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll index eb368471b1d84c..7dadeb5d72de09 100644 --- a/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll +++ b/llvm/test/Transforms/VectorCombine/AArch64/shuffletoidentity.ll @@ -13,8 +13,21 @@ define <8 x i8> @trivial(<8 x i8> %a) { ret <8 x i8> %r } -define <8 x i8> @add(<8 x i8> %a, <8 x i8> %b) { -; CHECK-LABEL: @add( +define <4 x i32> @add_same_operands(<4 x i32> %x) { +; CHECK-LABEL: @add_same_operands( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i32> [[REVSHUF]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %add = add <4 x i32> %shuf, %shuf + %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> + ret <4 x i32> %revshuf +} + +define <8 x i8> @add_different_operands(<8 x i8> %a, <8 x i8> %b) { +; CHECK-LABEL: @add_different_operands( ; CHECK-NEXT: [[R:%.*]] = add <8 x i8> [[A:%.*]], [[B:%.*]] ; CHECK-NEXT: ret <8 x i8> [[R]] ; @@ -356,8 +369,23 @@ define <8 x i8> @inner_shuffle(<8 x i8> %a, <8 x i8> %b, <8 x i8> %c) { ret <8 x i8> %r } -define <8 x i8> @extrause_add(<8 x i8> %a, <8 x i8> %b) { -; CHECK-LABEL: @extrause_add( +define <4 x i32> @extrause_add_same_operands(<4 x i32> %x) { +; CHECK-LABEL: @extrause_add_same_operands( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ADD2:%.*]] = add <4 x i32> [[SHUF]], [[REVSHUF]] +; CHECK-NEXT: ret <4 x i32> [[ADD2]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %add = add <4 x i32> %shuf, %shuf + %revshuf = shufflevector <4 x i32> %add, <4 x i32> poison, <4 x i32> + %add2 = add <4 x i32> %shuf, %revshuf + ret <4 x i32> %add2 +} + +define <8 x i8> @extrause_add_different_operands(<8 x i8> %a, <8 x i8> %b) { +; CHECK-LABEL: @extrause_add_different_operands( ; CHECK-NEXT: [[AB:%.*]] = shufflevector <8 x i8> [[A:%.*]], <8 x i8> poison, <4 x i32> ; CHECK-NEXT: [[AT:%.*]] = shufflevector <8 x i8> [[A]], <8 x i8> poison, <4 x i32> ; CHECK-NEXT: [[BB:%.*]] = shufflevector <8 x i8> [[B:%.*]], <8 x i8> poison, <4 x i32> @@ -513,6 +541,63 @@ define <8 x half> @fma(<8 x half> %a, <8 x half> %b, <8 x half> %c) { ret <8 x half> %r } +define <4 x i64> @single_zext(<4 x i32> %x) { +; CHECK-LABEL: @single_zext( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ZEXT]], <4 x i64> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %zext = zext <4 x i32> %shuf to <4 x i64> + %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> + ret <4 x i64> %revshuf +} + +define <4 x i64> @not_zext(<4 x i32> %x) { +; CHECK-LABEL: @not_zext( +; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[X:%.*]] to <4 x i64> +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ZEXT]], <4 x i64> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] +; + %zext = zext <4 x i32> %x to <4 x i64> + %revshuf = shufflevector <4 x i64> %zext, <4 x i64> poison, <4 x i32> + ret <4 x i64> %revshuf +} + +define <4 x i64> @not_zext2(<4 x i32> %x) { +; CHECK-LABEL: @not_zext2( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> +; CHECK-NEXT: ret <4 x i64> [[ZEXT]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %zext = zext <4 x i32> %shuf to <4 x i64> + ret <4 x i64> %zext +} + +define i32 @not_bitcast(<4 x i8> %x) { +; CHECK-LABEL: @not_bitcast( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i8> [[X:%.*]], <4 x i8> poison, <4 x i32> +; CHECK-NEXT: [[BITCAST:%.*]] = bitcast <4 x i8> [[SHUF]] to i32 +; CHECK-NEXT: ret i32 [[BITCAST]] +; + %shuf = shufflevector <4 x i8> %x, <4 x i8> poison, <4 x i32> + %bitcast = bitcast <4 x i8> %shuf to i32 + ret i32 %bitcast +} + +define <8 x i16> @not_bitcast2(<4 x i32> %x, <8 x i16> %y) { +; CHECK-LABEL: @not_bitcast2( +; CHECK-NEXT: [[CAST:%.*]] = bitcast <4 x i32> [[X:%.*]] to <8 x i16> +; CHECK-NEXT: [[OUT:%.*]] = shufflevector <8 x i16> [[Y:%.*]], <8 x i16> [[CAST]], <8 x i32> +; CHECK-NEXT: ret <8 x i16> [[OUT]] +; + %cast = bitcast <4 x i32> %x to <8 x i16> + %out = shufflevector <8 x i16> %y, <8 x i16> %cast, <8 x i32> + ret <8 x i16> %out +} + define void @exttrunc(<8 x i32> %a, <8 x i32> %b, ptr %p) { ; CHECK-LABEL: @exttrunc( ; CHECK-NEXT: [[AB:%.*]] = shufflevector <8 x i32> [[A:%.*]], <8 x i32> poison, <4 x i32> @@ -667,6 +752,51 @@ define void @trunc(<8 x i64> %a, <8 x i64> %b, ptr %p) { ret void } +define <4 x i64> @zext_chain(<4 x i16> %x) { +; CHECK-LABEL: @zext_chain( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i16> [[X:%.*]], <4 x i16> poison, <4 x i32> +; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i16> [[SHUF]] to <4 x i32> +; CHECK-NEXT: [[SEXT:%.*]] = sext <4 x i32> [[ZEXT]] to <4 x i64> +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[SEXT]], <4 x i64> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] +; + %shuf = shufflevector <4 x i16> %x, <4 x i16> poison, <4 x i32> + %zext = zext <4 x i16> %shuf to <4 x i32> + %sext = sext <4 x i32> %zext to <4 x i64> + %revshuf = shufflevector <4 x i64> %sext, <4 x i64> poison, <4 x i32> + ret <4 x i64> %revshuf +} + +define <4 x i32> @add_chain(<4 x i32> %x) { +; CHECK-LABEL: @add_chain( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ADD:%.*]] = add <4 x i32> [[SHUF]], [[SHUF]] +; CHECK-NEXT: [[ADD2:%.*]] = add <4 x i32> [[ADD]], [[ADD]] +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i32> [[ADD2]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i32> [[REVSHUF]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %add = add <4 x i32> %shuf, %shuf + %add2 = add <4 x i32> %add, %add + %revshuf = shufflevector <4 x i32> %add2, <4 x i32> poison, <4 x i32> + ret <4 x i32> %revshuf +} + +define <4 x i64> @zext_add_chain(<4 x i32> %x) { +; CHECK-LABEL: @zext_add_chain( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[ZEXT:%.*]] = zext <4 x i32> [[SHUF]] to <4 x i64> +; CHECK-NEXT: [[ADD:%.*]] = add <4 x i64> [[ZEXT]], [[ZEXT]] +; CHECK-NEXT: [[REVSHUF:%.*]] = shufflevector <4 x i64> [[ADD]], <4 x i64> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i64> [[REVSHUF]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %zext = zext <4 x i32> %shuf to <4 x i64> + %add = add <4 x i64> %zext, %zext + %revshuf = shufflevector <4 x i64> %add, <4 x i64> poison, <4 x i32> + ret <4 x i64> %revshuf +} + define <8 x i8> @intrinsics_minmax(<8 x i8> %a, <8 x i8> %b) { ; CHECK-LABEL: @intrinsics_minmax( ; CHECK-NEXT: [[TMP1:%.*]] = call <8 x i8> @llvm.smin.v8i8(<8 x i8> [[A:%.*]], <8 x i8> [[B:%.*]]) @@ -847,5 +977,33 @@ define <4 x i8> @singleop(<4 x i8> %a, <4 x i8> %b) { ret <4 x i8> %r } +define <4 x i64> @cast_mismatched_types(<4 x i32> %x) { +; CHECK-LABEL: @cast_mismatched_types( +; CHECK-NEXT: [[SHUF:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <2 x i32> +; CHECK-NEXT: [[ZEXT:%.*]] = zext <2 x i32> [[SHUF]] to <2 x i64> +; CHECK-NEXT: [[EXTSHUF:%.*]] = shufflevector <2 x i64> [[ZEXT]], <2 x i64> poison, <4 x i32> +; CHECK-NEXT: ret <4 x i64> [[EXTSHUF]] +; + %shuf = shufflevector <4 x i32> %x, <4 x i32> poison, <2 x i32> + %zext = zext <2 x i32> %shuf to <2 x i64> + %extshuf = shufflevector <2 x i64> %zext, <2 x i64> poison, <4 x i32> + ret <4 x i64> %extshuf +} + +define <4 x float> @fadd_mismatched_types(<4 x float> %x, <4 x float> %y) { +; CHECK-LABEL: @fadd_mismatched_types( +; CHECK-NEXT: [[SHUF_X:%.*]] = shufflevector <4 x float> [[X:%.*]], <4 x float> poison, <2 x i32> +; CHECK-NEXT: [[SHUF_Y:%.*]] = shufflevector <4 x float> [[Y:%.*]], <4 x float> poison, <2 x i32> +; CHECK-NEXT: [[FADD:%.*]] = fadd fast <2 x float> [[SHUF_X]], [[SHUF_Y]] +; CHECK-NEXT: [[EXTSHUF:%.*]] = shufflevector <2 x float> [[FADD]], <2 x float> poison, <4 x i32> +; CHECK-NEXT: ret <4 x float> [[EXTSHUF]] +; + %shuf.x = shufflevector <4 x float> %x, <4 x float> poison, <2 x i32> + %shuf.y = shufflevector <4 x float> %y, <4 x float> poison, <2 x i32> + %fadd = fadd fast <2 x float> %shuf.x, %shuf.y + %extshuf = shufflevector <2 x float> %fadd, <2 x float> poison, <4 x i32> + ret <4 x float> %extshuf +} + declare void @use(<4 x i8>)