1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -instcombine -S | FileCheck %s 3 4define<4 x float> @foo(<4 x float> %x) { 5 %ins1 = insertelement<4 x float> %x, float 1.0, i32 1 6 %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 7 ret<4 x float> %ins2 8} 9 10; insertelements should fold to shuffle 11; CHECK-LABEL: @foo 12; CHECK-NEXT: shufflevector <4 x float> %{{.+}}, <4 x float> <float undef, float 1.000000e+00, float 2.000000e+00, float undef>, <4 x i32> <i32 0, i32 5, i32 6, i32 3> 13; CHECK-NEXT: ret <4 x float> % 14 15define<4 x float> @bar(<4 x float> %x, float %a) { 16 %ins1 = insertelement<4 x float> %x, float %a, i32 1 17 %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 18 ret<4 x float> %ins2 19} 20 21; CHECK-LABEL: @bar 22; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float %{{.+}}, i32 1 23; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 24; CHECK-NEXT: ret <4 x float> % 25 26define<4 x float> @baz(<4 x float> %x, i32 %a) { 27 %ins1 = insertelement<4 x float> %x, float 1.0, i32 1 28 %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 %a 29 ret<4 x float> %ins2 30} 31 32; CHECK-LABEL: @baz 33; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 1 34; CHECK-NEXT: insertelement <4 x float> %ins1, float 2.000000e+00, i32 % 35; CHECK-NEXT: ret <4 x float> % 36 37define<4 x float> @bazz(<4 x float> %x, i32 %a) { 38 %ins1 = insertelement<4 x float> %x, float 1.0, i32 3 39 %ins2 = insertelement<4 x float> %ins1, float 5.0, i32 %a 40 %ins3 = insertelement<4 x float> %ins2, float 3.0, i32 2 41 %ins4 = insertelement<4 x float> %ins3, float 1.0, i32 1 42 %ins5 = insertelement<4 x float> %ins4, float 2.0, i32 2 43 %ins6 = insertelement<4 x float> %ins5, float 7.0, i32 %a 44 ret<4 x float> %ins6 45} 46 47; insertelements should fold to shuffle 48; CHECK-LABEL: @bazz 49; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 3 50; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 5.000000e+00, i32 % 51; CHECK-NEXT: shufflevector <4 x float> %{{.+}}, <4 x float> <float undef, float 1.000000e+00, float 2.000000e+00, float undef>, <4 x i32> <i32 0, i32 5, i32 6, i32 3> 52; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 7.000000e+00, i32 % 53; CHECK-NEXT: ret <4 x float> % 54 55define<4 x float> @bazzz(<4 x float> %x) { 56 %ins1 = insertelement<4 x float> %x, float 1.0, i32 5 57 %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 58 ret<4 x float> %ins2 59} 60 61; CHECK-LABEL: @bazzz 62; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 63; CHECK-NEXT: ret <4 x float> % 64 65define<4 x float> @bazzzz(<4 x float> %x) { 66 %ins1 = insertelement<4 x float> %x, float 1.0, i32 undef 67 %ins2 = insertelement<4 x float> %ins1, float 2.0, i32 2 68 ret<4 x float> %ins2 69} 70 71; CHECK-LABEL: @bazzzz 72; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 1.000000e+00, i32 undef 73; CHECK-NEXT: insertelement <4 x float> %{{.+}}, float 2.000000e+00, i32 2 74; CHECK-NEXT: ret <4 x float> % 75 76define<4 x float> @bazzzzz() { 77 %ins1 = insertelement <4 x float> insertelement (<4 x float> <float 1.0, float 2.0, float 3.0, float undef>, float 4.0, i32 3), float 5.0, i32 1 78 %ins2 = insertelement<4 x float> %ins1, float 10.0, i32 2 79 ret<4 x float> %ins2 80} 81 82; insertelements should fold to shuffle 83; CHECK-LABEL: @bazzzzz 84; CHECK-NEXT: ret <4 x float> <float 1.000000e+00, float 5.000000e+00, float 1.000000e+01, float 4.000000e+00> 85 86define<4 x float> @bazzzzzz(<4 x float> %x, i32 %a) { 87 %ins1 = insertelement <4 x float> insertelement (<4 x float> shufflevector (<4 x float> undef, <4 x float> <float 1.0, float 2.0, float 3.0, float 4.0> , <4 x i32> <i32 0, i32 5, i32 undef, i32 6> ), float 4.0, i32 3), float 5.0, i32 1 88 ret<4 x float> %ins1 89} 90 91; insertelements should fold to shuffle 92; CHECK-LABEL: @bazzzzz 93; CHECK-NEXT: ret <4 x float> <float undef, float 5.000000e+00, float undef, float 4.000000e+00> 94 95