Skip to content

Commit e4d4ac0

Browse files
bokrzesipszymich
authored andcommitted
Revert "[LLVM16][StatelessToStateful] Case where BUFFER_OFFSET doesn't seem to be 0"
Revert "[LLVM16][StatelessToStateful] Case where BUFFER_OFFSET doesn't seem to be 0" (cherry picked from commit e5f2c15)
1 parent cbc76e8 commit e4d4ac0

File tree

3 files changed

+11
-211
lines changed

3 files changed

+11
-211
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/StatelessToStateful/StatelessToStateful.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -527,35 +527,15 @@ static alignment_t determinePointerAlignment(Value *Ptr, const DataLayout &DL, A
527527
// 1) Examine uses: look for loads/stores (which may carry explicit
528528
// alignment) or a GEP that reveals an ABI alignment from its element
529529
// type.
530-
531-
// We're saving users into the queue
532-
// in order to track bitcasts
533-
std::queue<Instruction *> queue;
534-
535530
for (User *U : Ptr->users()) {
536-
if (auto *I = dyn_cast<Instruction>(U)) {
537-
queue.push(I);
538-
}
539-
}
540-
541-
while (queue.size() > 0) {
542-
auto U = queue.front();
543-
queue.pop();
544-
545531
if (auto *LI = dyn_cast<LoadInst>(U)) {
546532
// Load has an explicit alignment.
547533
alignment_t LdAlign = LI->getAlign().value();
548534
if (LdAlign > BestAlign)
549535
BestAlign = LdAlign;
550-
} else if (auto *cast = dyn_cast<BitCastInst>(U)) {
551-
for (User *U : cast->users()) {
552-
if (auto *I = dyn_cast<Instruction>(U)) {
553-
queue.push(I);
554-
}
555-
}
556536
} else if (auto *SI = dyn_cast<StoreInst>(U)) {
557537
// Store sets alignment only if the pointer we store into is Ptr.
558-
if (SI->getPointerOperand()->stripPointerCasts() == Ptr) {
538+
if (SI->getPointerOperand() == Ptr) {
559539
alignment_t StAlign = SI->getAlign().value();
560540
if (StAlign > BestAlign)
561541
BestAlign = StAlign;
@@ -1120,12 +1100,6 @@ void StatelessToStateful::finalizeArgInitialValue(Function *F) {
11201100
return;
11211101
}
11221102

1123-
#if LLVM_VERSION_MAJOR >= 16
1124-
// Disabling this transformation/optimization because the assumption about BufferOffset being 0 doesn't seem to be true
1125-
// More details in PR / blame.
1126-
return;
1127-
#endif
1128-
11291103
Module *M = F->getParent();
11301104
Type *int32Ty = Type::getInt32Ty(M->getContext());
11311105
Value *ZeroValue = ConstantInt::get(int32Ty, 0);

IGC/Compiler/tests/StatelessToStateful/Bindful/determine_pointer_size_casts.ll

Lines changed: 0 additions & 162 deletions
This file was deleted.

IGC/Compiler/tests/StatelessToStateful/Bindful/has_non_kernel_arg_LdSt.ll

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
;============================ end_copyright_notice =============================
99
;
1010
; REQUIRES: regkeys
11-
; RUN: igc_opt --typed-pointers --regkey DumpHasNonKernelArgLdSt=1 --regkey EnableOptionalBufferOffset=1 --regkey EnableSupportBufferOffset=1 -enable-debugify -igc-stateless-to-stateful-resolution -igc-serialize-metadata -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,%LLVM_DEPENDENT_CHECK_PREFIX%
12-
; RUN: igc_opt --opaque-pointers --regkey DumpHasNonKernelArgLdSt=1 --regkey EnableOptionalBufferOffset=1 --regkey EnableSupportBufferOffset=1 -enable-debugify -igc-stateless-to-stateful-resolution -igc-serialize-metadata -S < %s 2>&1 | FileCheck %s --check-prefixes=CHECK,%LLVM_DEPENDENT_CHECK_PREFIX%
11+
; RUN: igc_opt --typed-pointers --regkey DumpHasNonKernelArgLdSt=1 --regkey EnableOptionalBufferOffset=1 --regkey EnableSupportBufferOffset=1 -enable-debugify -igc-stateless-to-stateful-resolution -igc-serialize-metadata -S < %s 2>&1 | FileCheck %s
1312
; ------------------------------------------------
1413
; StatelessToStateful
1514
; ------------------------------------------------
@@ -19,29 +18,18 @@
1918
; CHECK-NOT: WARNING
2019
; CHECK: CheckModuleDebugify: PASS
2120

21+
2222
define spir_kernel void @func_b(i32 %n, i32 addrspace(1)* %r, <8 x i32> %r0, <8 x i32> %payloadHeader, i8* %privateBase, i8 addrspace(1)* %s2, i8 addrspace(1)* %s3, i32 %s4, i32 %s5, i32 %bufferOffset) #0 {
2323
; CHECK-LABEL: @func_b(
2424
; CHECK-NEXT: entry:
25-
26-
; CHECK-LLVM-16: %0 = add i32 %bufferOffset, 64
27-
; CHECK-LLVM-16: %1 = add i32 %bufferOffset, 64
28-
29-
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, {{ptr|i32}} addrspace(1){{.*}} [[R:%.*]], i32 16, !dbg [[DBG104:![0-9]+]]
30-
; CHECK-NEXT: call void @llvm.dbg.value(metadata {{ptr|i32}} addrspace(1){{.*}} [[TMP0]], metadata [[META100:![0-9]+]], metadata !DIExpression()), !dbg [[DBG104]]
31-
32-
; CHECK-LLVM-14: [[TMP1:%.*]] = inttoptr i32 64 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG105:![0-9]+]]
33-
; CHECK-LLVM-15: [[TMP1:%.*]] = inttoptr i32 64 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG105:![0-9]+]]
34-
; CHECK-LLVM-16: [[TMP1:%.*]] = inttoptr i32 %0 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG105:![0-9]+]]
35-
36-
; CHECK-NEXT: [[TMP2:%.*]] = load i32, {{ptr|i32}} addrspace({{[0-9]+}}){{.*}} [[TMP1]], align 4, !dbg [[DBG105]]
37-
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[TMP2]], metadata [[META102:![0-9]+]], metadata !DIExpression()), !dbg [[DBG105]]
38-
39-
; CHECK-LLVM-14: [[TMP3:%.*]] = inttoptr i32 64 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG106:![0-9]+]]
40-
; CHECK-LLVM-15: [[TMP3:%.*]] = inttoptr i32 64 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG106:![0-9]+]]
41-
; CHECK-LLVM-16: [[TMP3:%.*]] = inttoptr i32 %1 to {{ptr|i32}} addrspace({{[0-9]+}}){{.*}}, !dbg [[DBG106:![0-9]+]]
42-
43-
; CHECK-NEXT: store i32 [[N:%.*]], {{ptr|i32}} addrspace({{[0-9]+}}){{.*}} [[TMP3]], align 4, !dbg [[DBG106]]
44-
; CHECK-NEXT: ret void, !dbg [[DBG107:![0-9]+]]
25+
; CHECK-NEXT: [[TMP0:%.*]] = getelementptr i32, i32 addrspace(1)* [[R:%.*]], i32 16, !dbg [[DBG104:![0-9]+]]
26+
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 addrspace(1)* [[TMP0]], metadata [[META100:![0-9]+]], metadata !DIExpression()), !dbg [[DBG104]]
27+
; CHECK-NEXT: [[TMP1:%.*]] = inttoptr i32 64 to i32 addrspace(131072)*, !dbg [[DBG105:![0-9]+]]
28+
; CHECK-NEXT: [[TMP2:%.*]] = load i32, i32 addrspace(131072)* [[TMP1]], align 4, !dbg [[DBG105]]
29+
; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 [[TMP2]], metadata [[META102:![0-9]+]], metadata !DIExpression()), !dbg [[DBG105]]
30+
; CHECK-NEXT: [[TMP3:%.*]] = inttoptr i32 64 to i32 addrspace(131072)*, !dbg [[DBG106:![0-9]+]]
31+
; CHECK-NEXT: store i32 [[N:%.*]], i32 addrspace(131072)* [[TMP3]], align 4, !dbg [[DBG106]]
32+
; CHECK-NEXT: ret void, !dbg [[DBG107:![0-9]+]]
4533
;
4634
entry:
4735
%0 = getelementptr i32, i32 addrspace(1)* %r, i32 16

0 commit comments

Comments
 (0)