brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.8 KiB · 2683e1e Raw
97 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt < %s -passes=instcombine -S | FileCheck %s3 4declare void @use_f32(float)5declare void @use_v4f32(<4 x float>)6 7define <4 x float> @bitcast_inselt(i32 %x, <4 x i32> %v) {8; CHECK-LABEL: @bitcast_inselt(9; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[X:%.*]], i64 010; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>11; CHECK-NEXT:    ret <4 x float> [[R]]12;13  %xf = bitcast i32 %x to float14  %vf = bitcast <4 x i32> %v to <4 x float>15  %r = insertelement <4 x float> %vf, float %xf, i32 016  ret <4 x float> %r17}18 19define <4 x float> @bitcast_inselt_use1(i32 %x, <4 x i32> %v) {20; CHECK-LABEL: @bitcast_inselt_use1(21; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float22; CHECK-NEXT:    call void @use_f32(float [[XF]])23; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V:%.*]], i32 [[X]], i64 124; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>25; CHECK-NEXT:    ret <4 x float> [[R]]26;27  %xf = bitcast i32 %x to float28  call void @use_f32(float %xf)29  %vf = bitcast <4 x i32> %v to <4 x float>30  %r = insertelement <4 x float> %vf, float %xf, i32 131  ret <4 x float> %r32}33 34define <4 x float> @bitcast_inselt_use2(i32 %x, <4 x i32> %v, i32 %index) {35; CHECK-LABEL: @bitcast_inselt_use2(36; CHECK-NEXT:    [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float>37; CHECK-NEXT:    call void @use_v4f32(<4 x float> [[VF]])38; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x i32> [[V]], i32 [[X:%.*]], i32 [[INDEX:%.*]]39; CHECK-NEXT:    [[R:%.*]] = bitcast <4 x i32> [[TMP1]] to <4 x float>40; CHECK-NEXT:    ret <4 x float> [[R]]41;42  %xf = bitcast i32 %x to float43  %vf = bitcast <4 x i32> %v to <4 x float>44  call void @use_v4f32(<4 x float> %vf)45  %r = insertelement <4 x float> %vf, float %xf, i32 %index46  ret <4 x float> %r47}48 49; Negative test - 2 extra uses would require an extra instruction.50 51define <4 x float> @bitcast_inselt_use3(i32 %x, <4 x i32> %v) {52; CHECK-LABEL: @bitcast_inselt_use3(53; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float54; CHECK-NEXT:    call void @use_f32(float [[XF]])55; CHECK-NEXT:    [[VF:%.*]] = bitcast <4 x i32> [[V:%.*]] to <4 x float>56; CHECK-NEXT:    call void @use_v4f32(<4 x float> [[VF]])57; CHECK-NEXT:    [[R:%.*]] = insertelement <4 x float> [[VF]], float [[XF]], i64 058; CHECK-NEXT:    ret <4 x float> [[R]]59;60  %xf = bitcast i32 %x to float61  call void @use_f32(float %xf)62  %vf = bitcast <4 x i32> %v to <4 x float>63  call void @use_v4f32(<4 x float> %vf)64  %r = insertelement <4 x float> %vf, float %xf, i32 065  ret <4 x float> %r66}67 68; Negative test - wrong source type for vector.69 70define <2 x float> @bitcast_inselt_wrong_bitcast1(i32 %x, i64 %notv) {71; CHECK-LABEL: @bitcast_inselt_wrong_bitcast1(72; CHECK-NEXT:    [[XF:%.*]] = bitcast i32 [[X:%.*]] to float73; CHECK-NEXT:    [[VF:%.*]] = bitcast i64 [[NOTV:%.*]] to <2 x float>74; CHECK-NEXT:    [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i64 075; CHECK-NEXT:    ret <2 x float> [[R]]76;77  %xf = bitcast i32 %x to float78  %vf = bitcast i64 %notv to <2 x float>79  %r = insertelement <2 x float> %vf, float %xf, i32 080  ret <2 x float> %r81}82 83; Negative test - wrong source type for scalar.84 85define <2 x float> @bitcast_inselt_wrong_bitcast2(<2 x i16> %notscalar, <2 x i32> %v) {86; CHECK-LABEL: @bitcast_inselt_wrong_bitcast2(87; CHECK-NEXT:    [[XF:%.*]] = bitcast <2 x i16> [[NOTSCALAR:%.*]] to float88; CHECK-NEXT:    [[VF:%.*]] = bitcast <2 x i32> [[V:%.*]] to <2 x float>89; CHECK-NEXT:    [[R:%.*]] = insertelement <2 x float> [[VF]], float [[XF]], i64 090; CHECK-NEXT:    ret <2 x float> [[R]]91;92  %xf = bitcast <2 x i16> %notscalar to float93  %vf = bitcast <2 x i32> %v to <2 x float>94  %r = insertelement <2 x float> %vf, float %xf, i32 095  ret <2 x float> %r96}97