[llvm] r361051 - [InstCombine] add tests for insertelement with bitcasted operands; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Fri May 17 10:23:13 PDT 2019


Author: spatel
Date: Fri May 17 10:23:13 2019
New Revision: 361051

URL: http://llvm.org/viewvc/llvm-project?rev=361051&view=rev
Log:
[InstCombine] add tests for insertelement with bitcasted operands; NFC

Added:
    llvm/trunk/test/Transforms/InstCombine/insertelement-bitcast.ll

Added: llvm/trunk/test/Transforms/InstCombine/insertelement-bitcast.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/insertelement-bitcast.ll?rev=361051&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/insertelement-bitcast.ll (added)
+++ llvm/trunk/test/Transforms/InstCombine/insertelement-bitcast.ll Fri May 17 10:23:13 2019
@@ -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
+}
+




More information about the llvm-commits mailing list