2 ; RUN: opt < %s -passes=newgvn -S | FileCheck %s
4 declare void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> , <2 x i32*> , i32 , <2 x i1> )
5 declare <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*>, i32, <2 x i1>, <2 x i32>)
7 ; This test ensures that masked scatter and gather operations, which take vectors of pointers,
8 ; do not have pointer aliasing ignored when being processed.
9 ; No scatter/gather calls should end up eliminated
10 ; CHECK: llvm.masked.gather
11 ; CHECK: llvm.masked.gather
12 ; CHECK: llvm.masked.scatter
13 ; CHECK: llvm.masked.gather
14 ; CHECK: llvm.masked.scatter
15 ; CHECK: llvm.masked.gather
16 define spir_kernel void @test(<2 x i32*> %in1, <2 x i32*> %in2, i32* %out) {
18 ; Just some temporary storage
21 %tmp.i = insertelement <2 x i32*> undef, i32* %tmp.0, i32 0
22 %tmp = insertelement <2 x i32*> %tmp.i, i32* %tmp.1, i32 1
23 ; Read from in1 and in2
24 %in1.v = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %in1, i32 1, <2 x i1> <i1 true, i1 true>, <2 x i32> undef) #1
25 %in2.v = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %in2, i32 1, <2 x i1> <i1 true, i1 true>, <2 x i32> undef) #1
26 ; Store in1 to the allocas
27 call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %in1.v, <2 x i32*> %tmp, i32 1, <2 x i1> <i1 true, i1 true>);
28 ; Read in1 from the allocas
29 ; This gather should alias the scatter we just saw
30 %tmp.v.0 = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %tmp, i32 1, <2 x i1> <i1 true, i1 true>, <2 x i32> undef) #1
31 ; Store in2 to the allocas
32 call void @llvm.masked.scatter.v2i32.v2p0i32(<2 x i32> %in2.v, <2 x i32*> %tmp, i32 1, <2 x i1> <i1 true, i1 true>);
33 ; Read in2 from the allocas
34 ; This gather should alias the scatter we just saw, and not be eliminated
35 %tmp.v.1 = call <2 x i32> @llvm.masked.gather.v2i32.v2p0i32(<2 x i32*> %tmp, i32 1, <2 x i1> <i1 true, i1 true>, <2 x i32> undef) #1
36 ; Store in2 to out for good measure
37 %tmp.v.1.0 = extractelement <2 x i32> %tmp.v.1, i32 0
38 %tmp.v.1.1 = extractelement <2 x i32> %tmp.v.1, i32 1
39 store i32 %tmp.v.1.0, i32* %out
40 %out.1 = getelementptr i32, i32* %out, i32 1
41 store i32 %tmp.v.1.1, i32* %out.1