Skip to content

Commit 0008382

Browse files
authored
remove dead-code from ReplacePointerBitcastPass (#1434)
That code was added to manage cases where the source type is smaller than the gep result type. Nowadays that case is handle in various other way making that if statement useless has no test is executing it. On top of that the new test added is suffering from it, so removing it is actualy fixing that test as well.
1 parent 94e64bb commit 0008382

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

lib/ReplacePointerBitcastPass.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,6 @@ clspv::ReplacePointerBitcastPass::run(Module &M, ModuleAnalysisManager &) {
743743

744744
DstTy = GEP->getResultElementType();
745745

746-
if (DynVal == nullptr &&
747-
GoThroughTypeAtOffset(DL, Builder, SrcTy, DstTy,
748-
CstVal * SmallerBitWidths, nullptr) != 0) {
749-
SrcTy = DstTy;
750-
}
751746
auto Idx =
752747
GetIdxsForTyFromOffset(DL, Builder, SrcTy, DstTy, CstVal, DynVal,
753748
SmallerBitWidths, GEP->getPointerOperand());
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
; RUN: clspv-opt %s -o %t --passes=replace-pointer-bitcast
2+
; RUN: FileCheck %s < %t
3+
4+
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
5+
target triple = "spir64-unknown-unknown"
6+
7+
; CHECK-COUNT-2: store <4 x i8>
8+
9+
define spir_kernel void @foo(ptr addrspace(1) %a, ptr addrspace(1) %b, i32 %i) {
10+
entry:
11+
%gep1 = getelementptr i32, ptr addrspace(1) %b, i32 %i
12+
%loadi8 = load <4 x i8>, ptr addrspace(1) %b, align 4
13+
%loadi32 = load i32, ptr addrspace(1) %gep1, align 4
14+
%gep3 = getelementptr <4 x i8>, ptr addrspace(1) %a, i32 %i
15+
store <4 x i8> %loadi8, ptr addrspace(1) %gep3, align 4
16+
%gep2 = getelementptr i32, ptr addrspace(1) %a, i32 1
17+
store i32 %loadi32, ptr addrspace(1) %gep2, align 4
18+
ret void
19+
}

0 commit comments

Comments
 (0)