<div dir="ltr">Hello,<div><br></div><div>I'm trying to generate some LLVM IR that uses the constant memory address space. A very simple program aborts from LLVM with the following: <span style="color:rgb(0,0,0);line-height:normal">LLVM ERROR: Cannot cast between two non-generic address spaces.</span></div><div><span style="color:rgb(0,0,0);line-height:normal"><br></span></div><div><span style="color:rgb(0,0,0);line-height:normal">Here's the program I'm trying to build:</span></div><br><div><div>; Function Attrs: nounwind</div><div>define void @kernel_blur1_s1_x___block_id_x(i32 %blur1.min.0, i32 %"blur1.s1.tent.x$r", i8 addrspace(1)* noalias nocapture %blur1.host, i8 addrspace(1)* noalias nocapture readonly %input.host, i8 addrspace(4)* noalias nocapture readonly %tent.host) #1 {</div><div>entry:</div><div>  %blur1.s1.x.__block_id_x = tail call i32 @llvm.nvvm.read.ptx.sreg.ctaid.x() #0</div><div>  %.__thread_id_x = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0</div><div>  %0 = shl i32 %blur1.s1.x.__block_id_x, 4</div><div>  %1 = add nsw i32 %0, %blur1.min.0</div><div>  %2 = add nsw i32 %1, %.__thread_id_x</div><div>  %3 = sub i32 %"blur1.s1.tent.x$r", %blur1.min.0</div><div>  %4 = add i32 %3, %2</div><div>  %5 = bitcast i8 addrspace(1)* %input.host to i16 addrspace(1)*</div><div>  %6 = sext i32 %4 to i64</div><div>  %7 = getelementptr inbounds i16, i16 addrspace(1)* %5, i64 %6</div><div>  %8 = load i16, i16 addrspace(1)* %7, align 2, !tbaa !8</div><div>  %9 = bitcast i8 addrspace(4)* %tent.host to i16 addrspace(4)*</div><div>  %10 = sext i32 %"blur1.s1.tent.x$r" to i64</div><div>  %11 = getelementptr inbounds i16, i16 addrspace(4)* %9, i64 %10</div><div>  %12 = load i16, i16 addrspace(4)* %11, align 2, !tbaa !9</div><div>  %13 = mul i16 %12, %8</div><div>  %14 = sub nsw i32 %2, %blur1.min.0</div><div>  %15 = bitcast i8 addrspace(1)* %blur1.host to i16 addrspace(1)*</div><div>  %16 = sext i32 %14 to i64</div><div>  %17 = getelementptr inbounds i16, i16 addrspace(1)* %15, i64 %16</div><div>  %18 = load i16, i16 addrspace(1)* %17, align 2, !tbaa !6</div><div>  %19 = add i16 %18, %13</div><div>  store i16 %19, i16 addrspace(1)* %17, align 2, !tbaa !6</div><div>  ret void</div><div>}</div></div><div><br></div><div>The program looks correct to me w.r.t. address spaces. The error seems to come from NVPTXDAGToDAGISel::SelectAddrSpaceCast, but I don't believe the program needs or uses any address space casts?</div><div><br></div><div>Please let me know if I'm missing any information you need to help diagnose the problem!</div><div><br></div><div>Thanks,</div><div>Dillon</div></div>