brintos

brintos / llvm-project-archived public Read only

0
0
Text · 8.2 KiB · ffc5508 Raw
183 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py2; RUN: opt -passes=instcombine -S < %s | FileCheck %s3 4define <4 x float> @good1(float %arg) {5; CHECK-LABEL: @good1(6; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> poison, float [[ARG:%.*]], i64 07; CHECK-NEXT:    [[T6:%.*]] = shufflevector <4 x float> [[T]], <4 x float> poison, <4 x i32> zeroinitializer8; CHECK-NEXT:    ret <4 x float> [[T6]]9;10  %t = insertelement <4 x float> undef, float %arg, i32 011  %t4 = insertelement <4 x float> %t, float %arg, i32 112  %t5 = insertelement <4 x float> %t4, float %arg, i32 213  %t6 = insertelement <4 x float> %t5, float %arg, i32 314  ret <4 x float> %t615}16 17define <4 x float> @good2(float %arg) {18; CHECK-LABEL: @good2(19; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x float> poison, float [[ARG:%.*]], i64 020; CHECK-NEXT:    [[T6:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> zeroinitializer21; CHECK-NEXT:    ret <4 x float> [[T6]]22;23  %t = insertelement <4 x float> undef, float %arg, i32 124  %t4 = insertelement <4 x float> %t, float %arg, i32 225  %t5 = insertelement <4 x float> %t4, float %arg, i32 026  %t6 = insertelement <4 x float> %t5, float %arg, i32 327  ret <4 x float> %t628}29 30define <4 x float> @good3(float %arg) {31; CHECK-LABEL: @good3(32; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> poison, float [[ARG:%.*]], i64 033; CHECK-NEXT:    [[T6:%.*]] = shufflevector <4 x float> [[T]], <4 x float> poison, <4 x i32> zeroinitializer34; CHECK-NEXT:    ret <4 x float> [[T6]]35;36  %t = insertelement <4 x float> zeroinitializer, float %arg, i32 037  %t4 = insertelement <4 x float> %t, float %arg, i32 138  %t5 = insertelement <4 x float> %t4, float %arg, i32 239  %t6 = insertelement <4 x float> %t5, float %arg, i32 340  ret <4 x float> %t641}42 43define <4 x float> @good4(float %arg) {44; CHECK-LABEL: @good4(45; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> poison, float [[ARG:%.*]], i64 046; CHECK-NEXT:    [[TMP1:%.*]] = fadd <4 x float> [[T]], [[T]]47; CHECK-NEXT:    [[T7:%.*]] = shufflevector <4 x float> [[TMP1]], <4 x float> poison, <4 x i32> zeroinitializer48; CHECK-NEXT:    ret <4 x float> [[T7]]49;50  %t = insertelement <4 x float> zeroinitializer, float %arg, i32 051  %t4 = insertelement <4 x float> %t, float %arg, i32 152  %t5 = insertelement <4 x float> %t4, float %arg, i32 253  %t6 = insertelement <4 x float> %t5, float %arg, i32 354  %t7 = fadd <4 x float> %t6, %t655  ret <4 x float> %t756}57 58define <4 x float> @good5(float %v) {59; CHECK-LABEL: @good5(60; CHECK-NEXT:    [[INS1:%.*]] = insertelement <4 x float> <float poison, float undef, float undef, float undef>, float [[V:%.*]], i64 061; CHECK-NEXT:    [[A1:%.*]] = fadd <4 x float> [[INS1]], [[INS1]]62; CHECK-NEXT:    [[INS4:%.*]] = shufflevector <4 x float> [[INS1]], <4 x float> poison, <4 x i32> zeroinitializer63; CHECK-NEXT:    [[RES:%.*]] = fadd <4 x float> [[A1]], [[INS4]]64; CHECK-NEXT:    ret <4 x float> [[RES]]65;66  %ins1 = insertelement <4 x float> undef, float %v, i32 067  %a1 = fadd <4 x float> %ins1, %ins168  %ins2 = insertelement<4 x float> %ins1, float %v, i32 169  %ins3 = insertelement<4 x float> %ins2, float %v, i32 270  %ins4 = insertelement<4 x float> %ins3, float %v, i32 371  %res = fadd <4 x float> %a1, %ins472  ret <4 x float> %res73}74 75; The insert is changed to allow the canonical shuffle-splat pattern from element 0.76 77define <4 x float> @splat_undef1(float %arg) {78; CHECK-LABEL: @splat_undef1(79; CHECK-NEXT:    [[T4:%.*]] = insertelement <4 x float> <float undef, float poison, float poison, float poison>, float [[ARG:%.*]], i64 180; CHECK-NEXT:    [[T5:%.*]] = insertelement <4 x float> [[T4]], float [[ARG]], i64 281; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x float> [[T5]], float [[ARG]], i64 382; CHECK-NEXT:    ret <4 x float> [[T6]]83;84  %t = insertelement <4 x float> undef, float %arg, i32 185  %t4 = insertelement <4 x float> %t, float %arg, i32 186  %t5 = insertelement <4 x float> %t4, float %arg, i32 287  %t6 = insertelement <4 x float> %t5, float %arg, i32 388  ret <4 x float> %t689}90 91; Re-uses the existing first insertelement.92 93define <4 x float> @splat_undef2(float %arg) {94; CHECK-LABEL: @splat_undef2(95; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> <float poison, float undef, float poison, float poison>, float [[ARG:%.*]], i64 096; CHECK-NEXT:    [[T5:%.*]] = insertelement <4 x float> [[T]], float [[ARG]], i64 297; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x float> [[T5]], float [[ARG]], i64 398; CHECK-NEXT:    ret <4 x float> [[T6]]99;100  %t = insertelement <4 x float> undef, float %arg, i32 0101  %t5 = insertelement <4 x float> %t, float %arg, i32 2102  %t6 = insertelement <4 x float> %t5, float %arg, i32 3103  ret <4 x float> %t6104}105 106define <4 x float> @bad3(float %arg, float %arg2) {107; CHECK-LABEL: @bad3(108; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> poison, float [[ARG:%.*]], i64 0109; CHECK-NEXT:    [[T4:%.*]] = insertelement <4 x float> [[T]], float [[ARG2:%.*]], i64 1110; CHECK-NEXT:    [[T5:%.*]] = insertelement <4 x float> [[T4]], float [[ARG]], i64 2111; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x float> [[T5]], float [[ARG]], i64 3112; CHECK-NEXT:    ret <4 x float> [[T6]]113;114  %t = insertelement <4 x float> undef, float %arg, i32 0115  %t4 = insertelement <4 x float> %t, float %arg2, i32 1116  %t5 = insertelement <4 x float> %t4, float %arg, i32 2117  %t6 = insertelement <4 x float> %t5, float %arg, i32 3118  ret <4 x float> %t6119}120 121define <1 x float> @bad4(float %arg) {122; CHECK-LABEL: @bad4(123; CHECK-NEXT:    [[T:%.*]] = insertelement <1 x float> poison, float [[ARG:%.*]], i64 0124; CHECK-NEXT:    ret <1 x float> [[T]]125;126  %t = insertelement <1 x float> undef, float %arg, i32 0127  ret <1 x float> %t128}129 130; Multiple undef elements are ok.131; TODO: Multiple uses triggers the transform at %t4, but we should sink/scalarize/CSE the splats?132 133define <4 x float> @splat_undef3(float %arg) {134; CHECK-LABEL: @splat_undef3(135; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> <float poison, float poison, float undef, float undef>, float [[ARG:%.*]], i64 0136; CHECK-NEXT:    [[T4:%.*]] = insertelement <4 x float> [[T]], float [[ARG]], i64 1137; CHECK-NEXT:    [[T5:%.*]] = insertelement <4 x float> [[T4]], float [[ARG]], i64 2138; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x float> [[T5]], float [[ARG]], i64 3139; CHECK-NEXT:    [[T7:%.*]] = fadd <4 x float> [[T6]], [[T4]]140; CHECK-NEXT:    ret <4 x float> [[T7]]141;142  %t = insertelement <4 x float> undef, float %arg, i32 0143  %t4 = insertelement <4 x float> %t, float %arg, i32 1144  %t5 = insertelement <4 x float> %t4, float %arg, i32 2145  %t6 = insertelement <4 x float> %t5, float %arg, i32 3146  %t7 = fadd <4 x float> %t6, %t4147  ret <4 x float> %t7148}149 150define <4 x float> @bad6(float %arg, i32 %k) {151; CHECK-LABEL: @bad6(152; CHECK-NEXT:    [[T:%.*]] = insertelement <4 x float> <float poison, float poison, float undef, float poison>, float [[ARG:%.*]], i64 0153; CHECK-NEXT:    [[T4:%.*]] = insertelement <4 x float> [[T]], float [[ARG]], i64 1154; CHECK-NEXT:    [[T5:%.*]] = insertelement <4 x float> [[T4]], float [[ARG]], i32 [[K:%.*]]155; CHECK-NEXT:    [[T6:%.*]] = insertelement <4 x float> [[T5]], float [[ARG]], i64 3156; CHECK-NEXT:    ret <4 x float> [[T6]]157;158  %t = insertelement <4 x float> undef, float %arg, i32 0159  %t4 = insertelement <4 x float> %t, float %arg, i32 1160  %t5 = insertelement <4 x float> %t4, float %arg, i32 %k161  %t6 = insertelement <4 x float> %t5, float %arg, i32 3162  ret <4 x float> %t6163}164 165define <4 x float> @bad7(float %v) {166; CHECK-LABEL: @bad7(167; CHECK-NEXT:    [[INS1:%.*]] = insertelement <4 x float> <float undef, float poison, float undef, float undef>, float [[V:%.*]], i64 1168; CHECK-NEXT:    [[A1:%.*]] = fadd <4 x float> [[INS1]], [[INS1]]169; CHECK-NEXT:    [[TMP1:%.*]] = insertelement <4 x float> [[INS1]], float [[V]], i64 0170; CHECK-NEXT:    [[TMP2:%.*]] = insertelement <4 x float> [[TMP1]], float [[V]], i64 2171; CHECK-NEXT:    [[INS4:%.*]] = insertelement <4 x float> [[TMP2]], float [[V]], i64 3172; CHECK-NEXT:    [[RES:%.*]] = fadd <4 x float> [[A1]], [[INS4]]173; CHECK-NEXT:    ret <4 x float> [[RES]]174;175  %ins1 = insertelement <4 x float> undef, float %v, i32 1176  %a1 = fadd <4 x float> %ins1, %ins1177  %ins2 = insertelement<4 x float> %ins1, float %v, i32 2178  %ins3 = insertelement<4 x float> %ins2, float %v, i32 3179  %ins4 = insertelement<4 x float> %ins3, float %v, i32 0180  %res = fadd <4 x float> %a1, %ins4181  ret <4 x float> %res182}183