Skip to content

Commit c3980c3

Browse files
ustachowigcbot
authored andcommitted
Add LIT Tests for ConstantCoalescing Alignment Checks
Adds new LIT tests to validate the functionality of the ConstantCoalescing::MergeUniformLoad function, specifically focusing on alignment checks.
1 parent 66bef34 commit c3980c3

File tree

1 file changed

+69
-7
lines changed

1 file changed

+69
-7
lines changed

IGC/Compiler/tests/ConstantCoalescing/ldraws-alignment.ll

Lines changed: 69 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
;=========================== begin_copyright_notice ============================
22
;
3-
; Copyright (C) 2022-2024 Intel Corporation
3+
; Copyright (C) 2022-2025 Intel Corporation
44
;
55
; SPDX-License-Identifier: MIT
66
;
77
;============================ end_copyright_notice =============================
8-
98
; RUN: igc_opt --opaque-pointers %s -S -o - -igc-constant-coalescing -instcombine -dce | FileCheck %s
109

1110
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f16:16:16-f32:32:32-f64:64:64-f80:128:128-v16:16:16-v24:32:32-v32:32:32-v48:64:64-v64:64:64-v96:128:128-v128:128:128-v192:256:256-v256:256:256-v512:512:512-v1024:1024:1024-a:64:64-f80:128:128-n8:16:32:64"
1211

12+
; Test Case 1: Basic Test Case with Power-of-2 Alignment
1313
define <4 x half> @f0(i32 %src) {
1414
entry:
1515
%bso = inttoptr i32 %src to ptr addrspace(2490373)
@@ -33,18 +33,80 @@ entry:
3333
; CHECK: [[RET:%.*]] = call <4 x half> @llvm.genx.GenISA.ldrawvector.indexed.v4f16.p2490373(ptr addrspace(2490373) [[BSO]], i32 [[OFF]], i32 4, i1 false)
3434
; CHECK: ret <4 x half> [[RET]]
3535

36+
; Test Case 2: Non-Power-of-2 Alignment
37+
define <4 x half> @f1(i32 %src) {
38+
entry:
39+
%bso = inttoptr i32 %src to ptr addrspace(2490373)
40+
%ox = shl i32 %src, 2
41+
%x = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %ox, i32 7, i1 false)
42+
%oy = add i32 %ox, 2
43+
%y = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %oy, i32 7, i1 false)
44+
%oz = add i32 %ox, 4
45+
%z = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %oz, i32 7, i1 false)
46+
%ow = add i32 %ox, 6
47+
%w = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %ow, i32 7, i1 false)
48+
%ret.x = insertelement <4 x half> undef, half %x, i32 0
49+
%ret.xy = insertelement <4 x half> %ret.x, half %y, i32 1
50+
%ret.xyz = insertelement <4 x half> %ret.xy, half %z, i32 2
51+
%ret.xyzw = insertelement <4 x half> %ret.xyz, half %w, i32 3
52+
ret <4 x half> %ret.xyzw
53+
}
54+
; CHECK-LABEL: define <4 x half> @f1
55+
; CHECK-NOT: call <4 x half> @llvm.genx.GenISA.ldrawvector.indexed.v4f16.p2490373
56+
57+
; Test Case 3: Offset Not a Multiple of Scalar Size
58+
define <4 x half> @f2(i32 %src) {
59+
entry:
60+
%bso = inttoptr i32 %src to ptr addrspace(2490373)
61+
%ox = shl i32 %src, 3
62+
%x = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %ox, i32 2, i1 false)
63+
%oy = add i32 %ox, 3
64+
%y = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %oy, i32 2, i1 false)
65+
%oz = add i32 %ox, 5
66+
%z = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %oz, i32 2, i1 false)
67+
%ow = add i32 %ox, 7
68+
%w = call half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373) %bso, i32 %ow, i32 2, i1 false)
69+
%ret.x = insertelement <4 x half> undef, half %x, i32 0
70+
%ret.xy = insertelement <4 x half> %ret.x, half %y, i32 1
71+
%ret.xyz = insertelement <4 x half> %ret.xy, half %z, i32 2
72+
%ret.xyzw = insertelement <4 x half> %ret.xyz, half %w, i32 3
73+
ret <4 x half> %ret.xyzw
74+
}
75+
; CHECK-LABEL: define <4 x half> @f2
76+
; CHECK-NOT: call <4 x half> @llvm.genx.GenISA.ldrawvector.indexed.v4f16.p249037
77+
78+
; Function Attrs: argmemonly nounwind readonly
79+
declare float @llvm.genx.GenISA.ldraw.indexed.f32.p2490373i8(ptr addrspace(2490373), i32, i32, i1) #0
80+
3681
; Function Attrs: argmemonly nounwind readonly
37-
declare float @llvm.genx.GenISA.ldraw.indexed.f32.p2490373i8(ptr addrspace(2490373), i32, i32, i1) argmemonly nounwind readonly
38-
declare half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373), i32, i32, i1) argmemonly nounwind readonly
82+
declare half @llvm.genx.GenISA.ldraw.indexed.f16.p2490373i8(ptr addrspace(2490373), i32, i32, i1) #0
3983

4084
; Function Attrs: argmemonly nounwind writeonly
41-
declare void @llvm.genx.GenISA.storeraw.indexed.p2490368i8.f32(ptr addrspace(2490373), i32, float, i32, i1) argmemonly nounwind writeonly
85+
declare void @llvm.genx.GenISA.storeraw.indexed.p2490368i8.f32(ptr addrspace(2490373), i32, float, i32, i1) #1
86+
87+
; Function Attrs: argmemonly nounwind readonly willreturn
88+
declare <1 x half> @llvm.genx.GenISA.ldrawvector.indexed.v1f16.p2490373(ptr addrspace(2490373), i32, i32, i1) #2
4289

90+
; Function Attrs: argmemonly nounwind readonly willreturn
91+
declare <2 x half> @llvm.genx.GenISA.ldrawvector.indexed.v2f16.p2490373(ptr addrspace(2490373), i32, i32, i1) #2
4392

44-
!igc.functions = !{!0}
93+
; Function Attrs: argmemonly nounwind readonly willreturn
94+
declare <4 x half> @llvm.genx.GenISA.ldrawvector.indexed.v4f16.p2490373(ptr addrspace(2490373), i32, i32, i1) #2
4595

46-
!0 = !{<4 x half> (i32)* @f0, !1}
96+
attributes #0 = { argmemonly nounwind readonly }
97+
attributes #1 = { argmemonly nounwind writeonly }
98+
attributes #2 = { argmemonly nounwind readonly willreturn }
4799

100+
!igc.functions = !{!0, !3, !6}
101+
102+
!0 = !{ptr @f0, !1}
48103
!1 = !{!2}
49104
!2 = !{!"function_type", i32 0}
50105

106+
!3 = !{ptr @f1, !4}
107+
!4 = !{!5}
108+
!5 = !{!"function_type", i32 0}
109+
110+
!6 = !{ptr @f2, !7}
111+
!7 = !{!8}
112+
!8 = !{!"function_type", i32 0}

0 commit comments

Comments
 (0)