Skip to content

Commit dd055a9

Browse files
vmustyaigcbot
authored andcommitted
Fix GEP lowering pass
The ptrtoint->inttoptr folding should handle vector values correctly.
1 parent e916f98 commit dd055a9

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

IGC/VectorCompiler/lib/GenXCodeGen/GenXGEPLowering.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,11 @@ Value *GenXGEPLowering::visitPtrToIntInst(PtrToIntInst &PTI) {
160160
auto *Ty = PTI.getType();
161161
Value *NewI = nullptr;
162162

163-
if (SrcTy->isPointerTy()) {
163+
if (SrcTy->isPtrOrPtrVectorTy()) {
164164
NewI = Builder->CreatePtrToInt(Src, Ty);
165165
NewI->takeName(&PTI);
166166
} else {
167-
IGC_ASSERT(SrcTy->isIntegerTy());
167+
IGC_ASSERT(SrcTy->isIntOrIntVectorTy());
168168
NewI = Builder->CreateIntCast(Src, Ty, false);
169169
}
170170

IGC/VectorCompiler/test/GenXGEPLowering/fold-ptrtoint.ll

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010

1111
target datalayout = "e-p:64:64-p6:32:32-i64:64-n8:16:32:64"
1212

13-
declare <32 x i32> @llvm.vc.internal.lsc.load.ugm.v32i32.v1i1.i64(<1 x i1>, i8, i8, i8, i8, i8, i64, i64, i16, i32, <32 x i32>) #4
13+
declare <32 x i32> @llvm.vc.internal.lsc.load.ugm.v32i32.v1i1.i64(<1 x i1>, i8, i8, i8, i8, i8, i64, i64, i16, i32, <32 x i32>)
14+
declare <32 x double> @llvm.vc.internal.lsc.load.ugm.v32f64.v32i1.v32i64(<32 x i1>, i8, i8, i8, i8, i8, i64, <32 x i64>, i16, i32, <32 x double>)
1415

1516
; CHECK-LABEL: @test_fold_cast
1617
define <32 x i32> @test_fold_cast(i8 addrspace(1)* align 8 %a) {
@@ -45,6 +46,26 @@ entry:
4546
ret <32 x i32> %res
4647
}
4748

49+
; CHECK-LABEL: @test_fold_cast_vector
50+
define <32 x double> @test_fold_cast_vector(<32 x i1> %mask, <32 x i8 addrspace(1)*> %a) {
51+
entry:
52+
%bitcast = bitcast <32 x i8 addrspace(1)*> %a to <32 x double addrspace(1)*>
53+
; CHECK: %pti = ptrtoint <32 x i8 addrspace(1)*> %a to <32 x i64>
54+
%pti = ptrtoint <32 x double addrspace(1)*> %bitcast to <32 x i64>
55+
%res = call <32 x double> @llvm.vc.internal.lsc.load.ugm.v32f64.v32i1.v32i64(<32 x i1> %mask, i8 3, i8 4, i8 1, i8 0, i8 0, i64 0, <32 x i64> %pti, i16 1, i32 0, <32 x double> undef)
56+
ret <32 x double> %res
57+
}
58+
59+
; CHECK-LABEL: @test_fold_itp_vector
60+
define <32 x double> @test_fold_itp_vector(<32 x i1> %mask, <32 x i64> %a) {
61+
entry:
62+
%itp = inttoptr <32 x i64> %a to <32 x double addrspace(1)*>
63+
%pti = ptrtoint <32 x double addrspace(1)*> %itp to <32 x i64>
64+
; CHECK: %res = call <32 x double> @llvm.vc.internal.lsc.load.ugm.v32f64.v32i1.v32i64(<32 x i1> %mask, i8 3, i8 4, i8 1, i8 0, i8 0, i64 0, <32 x i64> %a, i16 1, i32 0, <32 x double> undef)
65+
%res = call <32 x double> @llvm.vc.internal.lsc.load.ugm.v32f64.v32i1.v32i64(<32 x i1> %mask, i8 3, i8 4, i8 1, i8 0, i8 0, i64 0, <32 x i64> %pti, i16 1, i32 0, <32 x double> undef)
66+
ret <32 x double> %res
67+
}
68+
4869
; CHECK-LABEL: @test_cross_block
4970
define void @test_cross_block(i64 %a, i32 %b) {
5071
entry:

0 commit comments

Comments
 (0)