diff --git a/llvm/test/Transforms/InstCombine/vector-casts.ll b/llvm/test/Transforms/InstCombine/vector-casts.ll index 308ca141ac6da..6bb4f4566bfb0 100644 --- a/llvm/test/Transforms/InstCombine/vector-casts.ll +++ b/llvm/test/Transforms/InstCombine/vector-casts.ll @@ -411,3 +411,116 @@ define <2 x i64> @zext_less_casting_with_wideop(<2 x i64> %x, <2 x i64> %y) { ret <2 x i64> %r } +define <4 x float> @sitofp_shuf(<4 x i32> %x) { +; CHECK-LABEL: @sitofp_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = sitofp <4 x i32> [[S]] to <4 x float> +; CHECK-NEXT: ret <4 x float> [[R]] +; + %s = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %r = sitofp <4 x i32> %s to <4 x float> + ret <4 x float> %r +} + +define <3 x half> @uitofp_shuf(<3 x i16> %x) { +; CHECK-LABEL: @uitofp_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <3 x i16> [[X:%.*]], <3 x i16> poison, <3 x i32> +; CHECK-NEXT: [[R:%.*]] = uitofp <3 x i16> [[S]] to <3 x half> +; CHECK-NEXT: ret <3 x half> [[R]] +; + %s = shufflevector <3 x i16> %x, <3 x i16> poison, <3 x i32> + %r = uitofp <3 x i16> %s to <3 x half> + ret <3 x half> %r +} + +define <4 x i64> @fptosi_shuf(<4 x double> %x) { +; CHECK-LABEL: @fptosi_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x double> [[X:%.*]], <4 x double> poison, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = fptosi <4 x double> [[S]] to <4 x i64> +; CHECK-NEXT: ret <4 x i64> [[R]] +; + %s = shufflevector <4 x double> %x, <4 x double> poison, <4 x i32> + %r = fptosi <4 x double> %s to <4 x i64> + ret <4 x i64> %r +} + +define <2 x i32> @fptoui_shuf(<2 x float> %x) { +; CHECK-LABEL: @fptoui_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <2 x i32> +; CHECK-NEXT: [[R:%.*]] = fptoui <2 x float> [[S]] to <2 x i32> +; CHECK-NEXT: ret <2 x i32> [[R]] +; + %s = shufflevector <2 x float> %x, <2 x float> poison, <2 x i32> + %r = fptoui <2 x float> %s to <2 x i32> + ret <2 x i32> %r +} + +define <4 x half> @narrowing_sitofp_shuf(<4 x i32> %x) { +; CHECK-LABEL: @narrowing_sitofp_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = sitofp <4 x i32> [[S]] to <4 x half> +; CHECK-NEXT: ret <4 x half> [[R]] +; + %s = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %r = sitofp <4 x i32> %s to <4 x half> + ret <4 x half> %r +} + +define <4 x double> @widening_uitofp_shuf(<4 x i32> %x) { +; CHECK-LABEL: @widening_uitofp_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = uitofp <4 x i32> [[S]] to <4 x double> +; CHECK-NEXT: ret <4 x double> [[R]] +; + %s = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + %r = uitofp <4 x i32> %s to <4 x double> + ret <4 x double> %r +} + +define <3 x i64> @fptosi_narrowing_shuf(<4 x double> %x) { +; CHECK-LABEL: @fptosi_narrowing_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x double> [[X:%.*]], <4 x double> poison, <3 x i32> +; CHECK-NEXT: [[R:%.*]] = fptosi <3 x double> [[S]] to <3 x i64> +; CHECK-NEXT: ret <3 x i64> [[R]] +; + %s = shufflevector <4 x double> %x, <4 x double> poison, <3 x i32> + %r = fptosi <3 x double> %s to <3 x i64> + ret <3 x i64> %r +} + +define <3 x i32> @fptoui_widening_shuf(<2 x float> %x) { +; CHECK-LABEL: @fptoui_widening_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x float> [[X:%.*]], <2 x float> poison, <3 x i32> +; CHECK-NEXT: [[R:%.*]] = fptoui <3 x float> [[S]] to <3 x i32> +; CHECK-NEXT: ret <3 x i32> [[R]] +; + %s = shufflevector <2 x float> %x, <2 x float> poison, <3 x i32> + %r = fptoui <3 x float> %s to <3 x i32> + ret <3 x i32> %r +} + +define <4 x half> @narrowing_sitofp_widening_shuf(<2 x i32> %x) { +; CHECK-LABEL: @narrowing_sitofp_widening_shuf( +; CHECK-NEXT: [[S:%.*]] = shufflevector <2 x i32> [[X:%.*]], <2 x i32> poison, <4 x i32> +; CHECK-NEXT: [[R:%.*]] = sitofp <4 x i32> [[S]] to <4 x half> +; CHECK-NEXT: ret <4 x half> [[R]] +; + %s = shufflevector <2 x i32> %x, <2 x i32> poison, <4 x i32> + %r = sitofp <4 x i32> %s to <4 x half> + ret <4 x half> %r +} + +declare void @use(<4 x i32>) + +define <4 x float> @sitofp_shuf_extra_use(<4 x i32> %x) { +; CHECK-LABEL: @sitofp_shuf_extra_use( +; CHECK-NEXT: [[S:%.*]] = shufflevector <4 x i32> [[X:%.*]], <4 x i32> poison, <4 x i32> +; CHECK-NEXT: call void @use(<4 x i32> [[S]]) +; CHECK-NEXT: [[R:%.*]] = sitofp <4 x i32> [[S]] to <4 x float> +; CHECK-NEXT: ret <4 x float> [[R]] +; + %s = shufflevector <4 x i32> %x, <4 x i32> poison, <4 x i32> + call void @use(<4 x i32> %s) + %r = sitofp <4 x i32> %s to <4 x float> + ret <4 x float> %r +}