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