brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.5 KiB · db22b3b Raw
103 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -S -passes=instcombine < %s | FileCheck %s3 4; This test checks that bitcast is moved after insertelement when both vector and scalar are5; bitcast from the same element type.6; inselt (bitcast VecSrc), (bitcast ScalarSrc), IdxOp7;  --> bitcast (inselt VecSrc, ScalarSrc, IdxOp)8define <vscale x 4 x float> @insertelement_bitcast(<vscale x 4 x i32> %vec, i32 %x) {9; CHECK-LABEL: @insertelement_bitcast(10; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <vscale x 4 x i32> [[VEC:%.*]], i32 [[X:%.*]], i64 011; CHECK-NEXT:    [[R:%.*]] = bitcast <vscale x 4 x i32> [[TMP1]] to <vscale x 4 x float>12; CHECK-NEXT:    ret <vscale x 4 x float> [[R]]13;14  %x_cast = bitcast i32 %x to float15  %vec_cast = bitcast <vscale x 4 x i32> %vec to <vscale x 4 x float>16  %r = insertelement <vscale x 4 x float> %vec_cast, float %x_cast, i32 017  ret <vscale x 4 x float> %r18}19 20; This test checks that code-path "Try to form a shuffle from a chain of extract-insert ops" is21; not taken when both extract and insert are scalable type.22; For scalable type, the vector length needed to create shuffle mask is not a compile-time constant.23; Meanwhile, for scalable type shuffle mask only support splat and undef in the current code base.24; Otherwise we crash at:25; "Assertion `isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"' failed."26define <vscale x 4 x i32> @insertelement_extractelement(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {27; CHECK-LABEL: @insertelement_extractelement(28; CHECK-NEXT:    [[T0:%.*]] = extractelement <vscale x 4 x i32> [[A:%.*]], i64 129; CHECK-NEXT:    [[T1:%.*]] = insertelement <vscale x 4 x i32> [[B:%.*]], i32 [[T0]], i64 030; CHECK-NEXT:    ret <vscale x 4 x i32> [[T1]]31;32  %t0 = extractelement <vscale x 4 x i32> %a, i32 133  %t1 = insertelement <vscale x 4 x i32> %b, i32 %t0, i32 034  ret <vscale x 4 x i32> %t135}36 37; This test checks that we are not attempting to create a shuffle from extract/insert chain,38; when extract is from a scalable type, and the insert vector is fixed-length.39define <4 x i32> @insertelement_extractelement_fixed_vec_extract_from_scalable(<vscale x 4 x i32> %a, <4 x i32> %b) {40; CHECK-LABEL: @insertelement_extractelement_fixed_vec_extract_from_scalable(41; CHECK-NEXT:    [[T0:%.*]] = extractelement <vscale x 4 x i32> [[A:%.*]], i64 142; CHECK-NEXT:    [[T1:%.*]] = insertelement <4 x i32> [[B:%.*]], i32 [[T0]], i64 043; CHECK-NEXT:    ret <4 x i32> [[T1]]44;45  %t0 = extractelement <vscale x 4 x i32> %a, i32 146  %t1 = insertelement <4 x i32> %b, i32 %t0, i32 047  ret <4 x i32> %t148}49 50; This test checks that the optimization "foldConstantInsEltInfoShuffle" is not taken for scalable type.51; Particularly the fold:52; insertelt (insertelt X, C1, CIndex1), C, CIndex53;  --> shufflevector X, CVec', Mask'54; For scalable type, the vector length needed to create shuffle mask is not a compile-time constant.55; Meanwhile, for scalable type shuffle mask only support splat and undef in the current code base.56; Otherwise we crash at:57; "Assertion `isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"' failed."58define <vscale x 4 x i32> @insertelement_insertelement(<vscale x 4 x i32> %vec) {59; CHECK-LABEL: @insertelement_insertelement(60; CHECK-NEXT:    [[T0:%.*]] = insertelement <vscale x 4 x i32> [[VEC:%.*]], i32 1, i64 161; CHECK-NEXT:    [[T1:%.*]] = insertelement <vscale x 4 x i32> [[T0]], i32 2, i64 262; CHECK-NEXT:    ret <vscale x 4 x i32> [[T1]]63;64  %t0 = insertelement <vscale x 4 x i32> %vec, i32 1, i32 165  %t1 = insertelement <vscale x 4 x i32> %t0, i32 2, i32 266  ret <vscale x 4 x i32> %t167}68 69; This test checks that the following insertelement sequence is not folded into shuffle splat.70; The length of scalable vector is unknown at compile-time. Therefore the following insertelements71; may not form a valid splat.72define <vscale x 4 x float> @insertelement_sequene_may_not_be_splat(float %x) {73; CHECK-LABEL: @insertelement_sequene_may_not_be_splat(74; CHECK-NEXT:    [[T0:%.*]] = insertelement <vscale x 4 x float> undef, float [[X:%.*]], i64 075; CHECK-NEXT:    [[T1:%.*]] = insertelement <vscale x 4 x float> [[T0]], float [[X]], i64 176; CHECK-NEXT:    [[T2:%.*]] = insertelement <vscale x 4 x float> [[T1]], float [[X]], i64 277; CHECK-NEXT:    [[T3:%.*]] = insertelement <vscale x 4 x float> [[T2]], float [[X]], i64 378; CHECK-NEXT:    ret <vscale x 4 x float> [[T3]]79;80  %t0 = insertelement <vscale x 4 x float> undef, float %x, i32 081  %t1 = insertelement <vscale x 4 x float> %t0, float %x, i32 182  %t2 = insertelement <vscale x 4 x float> %t1, float %x, i32 283  %t3 = insertelement <vscale x 4 x float> %t2, float %x, i32 384  ret <vscale x 4 x float> %t385}86 87; OSS-Fuzz #2741688; https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=2741689define void @ossfuzz_27416(i32 %v, ptr %p) {90; CHECK-LABEL: @ossfuzz_27416(91; CHECK-NEXT:    [[IN:%.*]] = insertelement <vscale x 4 x i32> undef, i32 [[V:%.*]], i64 092; CHECK-NEXT:    [[SPLAT:%.*]] = shufflevector <vscale x 4 x i32> [[IN]], <vscale x 4 x i32> poison, <vscale x 4 x i32> zeroinitializer93; CHECK-NEXT:    [[I1:%.*]] = insertelement <vscale x 4 x i32> [[SPLAT]], i32 undef, i64 12894; CHECK-NEXT:    store <vscale x 4 x i32> [[I1]], ptr [[P:%.*]], align 1695; CHECK-NEXT:    ret void96;97  %in = insertelement <vscale x 4 x i32> undef, i32 %v, i32 098  %splat = shufflevector <vscale x 4 x i32> %in, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer99  %I1 = insertelement <vscale x 4 x i32> %splat, i32 undef, i8 -128100  store <vscale x 4 x i32> %I1, ptr %p, align 16101  ret void102}103