1; RUN: opt %s -scalarizer -S -o - | FileCheck %s
2; RUN: opt %s -passes='function(scalarizer)' -S -o - | FileCheck %s
3
4; This input caused the scalarizer to replace & erase gathered results when
5; future gathered results depended on them being alive
6
7define dllexport spir_func <4 x i32> @main(float %a) {
8entry:
9  %i = insertelement <4 x float> undef, float %a, i32 0
10  br label %z
11
12y:
13; CHECK: %f.upto0 = insertelement <4 x i32> undef, i32 %b.i0, i32 0
14; CHECK: %f.upto1 = insertelement <4 x i32> %f.upto0, i32 %b.i0, i32 1
15; CHECK: %f.upto2 = insertelement <4 x i32> %f.upto1, i32 %b.i0, i32 2
16; CHECK: %f = insertelement <4 x i32> %f.upto2, i32 %b.i0, i32 3
17  %f = shufflevector <4 x i32> %b, <4 x i32> undef, <4 x i32> zeroinitializer
18  ret <4 x i32> %f
19
20z:
21; CHECK: %b.i0 = bitcast float %a to i32
22  %b = bitcast <4 x float> %i to <4 x i32>
23  br label %y
24}
25