Preserve integer index type for pointerref/pointerset.#342
Merged
Conversation
Member
Author
*** IR Dump After Promote heap allocation to stack (AllocOpt) ***
define ptx_kernel void @kernel({ i8 addrspace(1)*, i32, [2 x i32], i32 } %0, { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, { i8 addrspace(1)*, i32, [2 x i32], i32 } %2) local_unnamed_addr #1 !dbg !8 {
conversion:
%.fca.0.extract11 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 0
%.fca.1.extract12 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 1
%.fca.2.0.extract13 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 2, 0
%.fca.2.1.extract14 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 2, 1
%.fca.3.extract15 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 3
%.fca.0.extract1 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 0
%.fca.1.extract2 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 1
%.fca.2.0.extract3 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 2, 0
%.fca.2.1.extract4 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 2, 1
%.fca.3.extract5 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 3
%.fca.0.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 0
%.fca.1.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 1
%.fca.2.0.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 2, 0
%.fca.2.1.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 2, 1
%.fca.3.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 3
%3 = call {}*** @julia.get_pgcstack()
%4 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x(), !dbg !10, !range !23
%5 = add i32 %4, 1, !dbg !24
%6 = sub i32 %5, 1, !dbg !27
%7 = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x(), !dbg !29, !range !36
%8 = mul i32 %6, %7, !dbg !37
%9 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !39, !range !46
%10 = add i32 %9, 1, !dbg !47
%11 = add i32 %8, %10, !dbg !48
%12 = sub i32 %11, 1, !dbg !49
%13 = bitcast i8 addrspace(1)* %.fca.0.extract11 to float addrspace(1)*, !dbg !50
%14 = getelementptr inbounds float, float addrspace(1)* %13, i32 %12, !dbg !50
%15 = load float, float addrspace(1)* %14, align 4, !dbg !50, !tbaa !66
%16 = sub i32 %11, 1, !dbg !49
%17 = bitcast i8 addrspace(1)* %.fca.0.extract1 to float addrspace(1)*, !dbg !50
%18 = getelementptr inbounds float, float addrspace(1)* %17, i32 %16, !dbg !50
%19 = load float, float addrspace(1)* %18, align 4, !dbg !50, !tbaa !66
%20 = fadd float %15, %19, !dbg !69
%21 = sub i32 %11, 1, !dbg !72
%22 = bitcast i8 addrspace(1)* %.fca.0.extract to float addrspace(1)*, !dbg !73
%23 = getelementptr inbounds float, float addrspace(1)* %22, i32 %21, !dbg !73
store float %20, float addrspace(1)* %23, align 4, !dbg !73, !tbaa !66
ret void, !dbg !85
}
*** IR Dump After Combine redundant instructions (instcombine) ***
define ptx_kernel void @kernel({ i8 addrspace(1)*, i32, [2 x i32], i32 } %0, { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, { i8 addrspace(1)*, i32, [2 x i32], i32 } %2) local_unnamed_addr #1 !dbg !8 {
conversion:
%.fca.0.extract11 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %0, 0
%.fca.0.extract1 = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %1, 0
%.fca.0.extract = extractvalue { i8 addrspace(1)*, i32, [2 x i32], i32 } %2, 0
%3 = call {}*** @julia.get_pgcstack()
%4 = call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x(), !dbg !10, !range !23
%5 = call i32 @llvm.nvvm.read.ptx.sreg.ntid.x(), !dbg !24, !range !31
%6 = mul i32 %4, %5, !dbg !32
%7 = call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !35, !range !42
%8 = add i32 %6, %7, !dbg !43
%9 = bitcast i8 addrspace(1)* %.fca.0.extract11 to float addrspace(1)*, !dbg !45
%10 = sext i32 %8 to i64, !dbg !45
%11 = getelementptr inbounds float, float addrspace(1)* %9, i64 %10, !dbg !45
%12 = load float, float addrspace(1)* %11, align 4, !dbg !45, !tbaa !61
%13 = add i32 %6, %7, !dbg !43
%14 = bitcast i8 addrspace(1)* %.fca.0.extract1 to float addrspace(1)*, !dbg !45
%15 = sext i32 %13 to i64, !dbg !45
%16 = getelementptr inbounds float, float addrspace(1)* %14, i64 %15, !dbg !45
%17 = load float, float addrspace(1)* %16, align 4, !dbg !45, !tbaa !61
%18 = fadd float %12, %17, !dbg !64
%19 = add i32 %6, %7, !dbg !67
%20 = bitcast i8 addrspace(1)* %.fca.0.extract to float addrspace(1)*, !dbg !68
%21 = sext i32 %19 to i64, !dbg !68
%22 = getelementptr inbounds float, float addrspace(1)* %20, i64 %21, !dbg !68
store float %18, float addrspace(1)* %22, align 4, !dbg !68, !tbaa !61
ret void, !dbg !80
}Not sure why instcombine introduces i64 here. DL issue? EDIT: yeah the DL has an IndexType, let's try setting that. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For JuliaGPU/CUDA.jl#1895
Interestingly, we do still get an
i64. With a simple CUDAvaddkernel, the unoptimized LLVM IR is:i.e. no
i64. However, after optimization:So optimization sneaks in an
i64GEP? Which is too bad, as it means the compiled PTX code still contains some 64-bit instructions.