From: Sanjay Patel Date: Fri, 17 May 2019 17:23:13 +0000 (+0000) Subject: [InstCombine] add tests for insertelement with bitcasted operands; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7527749e866a14b943be1a32ac043fb36f3c773e;p=llvm [InstCombine] add tests for insertelement with bitcasted operands; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@361051 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/Transforms/InstCombine/insertelement-bitcast.ll b/test/Transforms/InstCombine/insertelement-bitcast.ll new file mode 100644 index 00000000000..92d2aeeff18 --- /dev/null +++ b/test/Transforms/InstCombine/insertelement-bitcast.ll @@ -0,0 +1,92 @@ +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py +; RUN: opt < %s -instcombine -S | FileCheck %s + +declare void @use_f32(float) +declare void @use_v4f32(<4 x float>) + +define <4 x float> @bitcast_inselt(i32 %x, <4 x i32> %v) { +; CHECK-LABEL: @bitcast_inselt( +; CHECK-NEXT: [[XF:%.*]] = bitcast i32 [[X:%.*]] to float +; CHECK-NEXT: [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i32 0 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xf = bitcast i32 %x to float + %vf = bitcast <4 x i32> %v to <4 x float> + %r = insertelement <4 x float> %vf, float %xf, i32 0 + ret <4 x float> %r +} + +define <4 x float> @bitcast_inselt_use1(i32 %x, <4 x i32> %v) { +; CHECK-LABEL: @bitcast_inselt_use1( +; CHECK-NEXT: [[XF:%.*]] = bitcast i32 [[X:%.*]] to float +; CHECK-NEXT: call void @use_f32(float [[XF]]) +; CHECK-NEXT: [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float> +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i32 1 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xf = bitcast i32 %x to float + call void @use_f32(float %xf) + %vf = bitcast <4 x i32> %v to <4 x float> + %r = insertelement <4 x float> %vf, float %xf, i32 1 + ret <4 x float> %r +} + +define <4 x float> @bitcast_inselt_use2(i32 %x, <4 x i32> %v, i32 %index) { +; CHECK-LABEL: @bitcast_inselt_use2( +; CHECK-NEXT: [[XF:%.*]] = bitcast i32 [[X:%.*]] to float +; CHECK-NEXT: [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float> +; CHECK-NEXT: call void @use_v4f32(<4 x float> [[VF]]) +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i32 [[INDEX:%.*]] +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xf = bitcast i32 %x to float + %vf = bitcast <4 x i32> %v to <4 x float> + call void @use_v4f32(<4 x float> %vf) + %r = insertelement <4 x float> %vf, float %xf, i32 %index + ret <4 x float> %r +} + +define <4 x float> @bitcast_inselt_use3(i32 %x, <4 x i32> %v) { +; CHECK-LABEL: @bitcast_inselt_use3( +; CHECK-NEXT: [[XF:%.*]] = bitcast i32 [[X:%.*]] to float +; CHECK-NEXT: call void @use_f32(float [[XF]]) +; CHECK-NEXT: [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float> +; CHECK-NEXT: call void @use_v4f32(<4 x float> [[VF]]) +; CHECK-NEXT: [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i32 0 +; CHECK-NEXT: ret <4 x float> [[R]] +; + %xf = bitcast i32 %x to float + call void @use_f32(float %xf) + %vf = bitcast <4 x i32> %v to <4 x float> + call void @use_v4f32(<4 x float> %vf) + %r = insertelement <4 x float> %vf, float %xf, i32 0 + ret <4 x float> %r +} + +define <2 x float> @bitcast_inselt_wrong_bitcast1(i32 %x, i64 %notv) { +; CHECK-LABEL: @bitcast_inselt_wrong_bitcast1( +; CHECK-NEXT: [[XF:%.*]] = bitcast i32 [[X:%.*]] to float +; CHECK-NEXT: [[VF:%.*]] = bitcast i64 [[NOTV:%.*]] to <2 x float> +; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i32 0 +; CHECK-NEXT: ret <2 x float> [[R]] +; + %xf = bitcast i32 %x to float + %vf = bitcast i64 %notv to <2 x float> + %r = insertelement <2 x float> %vf, float %xf, i32 0 + ret <2 x float> %r +} + +define <2 x float> @bitcast_inselt_wrong_bitcast2(<2 x i16> %notscalar, <2 x i32> %v) { +; CHECK-LABEL: @bitcast_inselt_wrong_bitcast2( +; CHECK-NEXT: [[XF:%.*]] = bitcast <2 x i16> [[NOTSCALAR:%.*]] to float +; CHECK-NEXT: [[VF:%.*]] = bitcast <2 x i32> [[V:%.*]] to <2 x float> +; CHECK-NEXT: [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i32 0 +; CHECK-NEXT: ret <2 x float> [[R]] +; + %xf = bitcast <2 x i16> %notscalar to float + %vf = bitcast <2 x i32> %v to <2 x float> + %r = insertelement <2 x float> %vf, float %xf, i32 0 + ret <2 x float> %r +} +