forked from GPUOpen-Drivers/llpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IntToPtrWithAdd.lgc
69 lines (56 loc) · 3.41 KB
/
IntToPtrWithAdd.lgc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
; Change inttoptr ( add x, const ) -> gep ( inttoptr x, const )
; RUN: lgc -mcpu=gfx900 -print-after=lgc-patch-peephole-opt -o /dev/null 2>&1 - <%s | FileCheck --check-prefixes=CHECK %s
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-ni:7"
target triple = "amdgcn--amdpal"
; Function Attrs: nounwind
define dllexport spir_func void @lgc.shader.VS.main(i64 %0, <4 x i32> addrspace(1)* %1) local_unnamed_addr #0 !lgc.shaderstage !10 {
; CHECK: IR Dump After Patch LLVM for peephole optimizations
; CHECK: [[INTTOPTR:%[0-9]+]] = inttoptr i64 %[[#]] to i32 addrspace(1)*
; CHECK: [[LOAD:%[0-9]+]] = load i32, i32 addrspace(1)* [[INTTOPTR]], align 4
; CHECK: [[INSERTELEMENT:%[0-9]+]] = insertelement <4 x i32> undef, i32 [[LOAD]], i{{32|64}} 0
; CHECK: [[INTTOPTR1:%[0-9]+]] = inttoptr i64 %[[#]] to i32 addrspace(1)*
; CHECK: [[GEP1:%[0-9]+]] = getelementptr i32, i32 addrspace(1)* [[INTTOPTR1]], i64 1
; CHECK: [[LOAD1:%[0-9]+]] = load i32, i32 addrspace(1)* [[GEP1]], align 4
; CHECK: [[INSERTELEMENT1:%[0-9]+]] = insertelement <4 x i32> [[INSERTELEMENT]], i32 [[LOAD1]], i{{32|64}} 1
; CHECK: [[INTTOPTR2:%[0-9]+]] = inttoptr i64 %[[#]] to i32 addrspace(1)*
; CHECK: [[GEP2:%[0-9]+]] = getelementptr i32, i32 addrspace(1)* [[INTTOPTR2]], i64 2
; CHECK: [[LOAD2:%[0-9]+]] = load i32, i32 addrspace(1)* [[GEP2]], align 4
; CHECK: [[INSERTELEMENT2:%[0-9]+]] = insertelement <4 x i32> [[INSERTELEMENT1]], i32 [[LOAD2]], i{{32|64}} 2
; CHECK: [[INTTOPTR3:%[0-9]+]] = inttoptr i64 %[[#]] to i32 addrspace(1)*
; CHECK: [[GEP3:%[0-9]+]] = getelementptr i32, i32 addrspace(1)* [[INTTOPTR3]], i64 3
; CHECK: [[LOAD3:%[0-9]+]] = load i32, i32 addrspace(1)* [[GEP3]], align 4
; CHECK: [[INSERTELEMENT3:%[0-9]+]] = insertelement <4 x i32> [[INSERTELEMENT2]], i32 [[LOAD3]], i{{32|64}} 3
; CHECK: store <4 x i32> [[INSERTELEMENT3]], <4 x i32> addrspace(1)* %[[#]], align 16
.entry:
%2 = inttoptr i64 %0 to i32 addrspace(1)*
%3 = load i32, i32 addrspace(1)* %2, align 4
%4 = insertelement <4 x i32> undef, i32 %3, i32 0
%5 = add i64 %0, 4
%6 = inttoptr i64 %5 to i32 addrspace(1)*
%7 = load i32, i32 addrspace(1)* %6, align 4
%8 = insertelement <4 x i32> %4, i32 %7, i32 1
%9 = add i64 %0, 8
%10 = inttoptr i64 %9 to i32 addrspace(1)*
%11 = load i32, i32 addrspace(1)* %10, align 4
%12 = insertelement <4 x i32> %8, i32 %11, i32 2
%13 = add i64 %0, 12
%14 = inttoptr i64 %13 to i32 addrspace(1)*
%15 = load i32, i32 addrspace(1)* %14, align 4
%16 = insertelement <4 x i32> %12, i32 %15, i32 3
store <4 x i32> %16, <4 x i32> addrspace(1)* %1
ret void
}
; Function Attrs: nounwind
declare [76 x i8] addrspace(4)* @lgc.create.load.push.constants.ptr.p4a76i8(...) local_unnamed_addr #0
; Function Attrs: nounwind readonly
declare <3 x float> @lgc.create.read.generic.input.v3f32(...) local_unnamed_addr #1
; Function Attrs: nounwind
declare void @lgc.create.write.generic.output(...) local_unnamed_addr #0
attributes #0 = { nounwind }
attributes #1 = { nounwind readonly }
!lgc.unlinked = !{!10}
!lgc.options = !{!0}
!lgc.options.VS = !{!1}
!0 = !{i32 739459867, i32 836497279, i32 -1935591037, i32 -652075177, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 2}
!1 = !{i32 801932830, i32 600683540, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 64, i32 0, i32 15, i32 3}
!10 = !{i32 1}