[llvm] [AMDGPU] Fix a crash caused by bitcast type mismatch (PR #215933)

Shilei Tian via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 13 06:15:51 PDT 2026


================
@@ -21,6 +21,28 @@ entry:
   ret void
 }
 
+define amdgpu_kernel void @test_bitcast_gen_4ptr_v2ptr(ptr addrspace(1) %out, i32 %idx) #0 {
+; CHECK-LABEL: define amdgpu_kernel void @test_bitcast_gen_4ptr_v2ptr(
+; CHECK-SAME: ptr addrspace(1) [[OUT:%.*]], i32 [[IDX:%.*]]) {
+; CHECK-NEXT:  [[ENTRY:.*:]]
+; CHECK-NEXT:    [[ALLOCA:%.*]] = freeze <4 x ptr> poison
+; CHECK-NEXT:    [[TMP0:%.*]] = ptrtoint <4 x ptr> [[ALLOCA]] to <4 x i64>
+; CHECK-NEXT:    [[TMP1:%.*]] = bitcast <4 x i64> [[TMP0]] to <2 x i128>
+; CHECK-NEXT:    [[TMP2:%.*]] = lshr i32 [[IDX]], 1
+; CHECK-NEXT:    [[TMP3:%.*]] = extractelement <2 x i128> [[TMP1]], i32 [[TMP2]]
+; CHECK-NEXT:    [[TMP4:%.*]] = bitcast i128 [[TMP3]] to <2 x i64>
+; CHECK-NEXT:    [[TMP5:%.*]] = inttoptr <2 x i64> [[TMP4]] to <2 x ptr>
+; CHECK-NEXT:    store <2 x ptr> [[TMP5]], ptr addrspace(1) [[OUT]], align 16
+; CHECK-NEXT:    ret void
+;
+entry:
+  %alloca = alloca [4 x ptr], align 16, addrspace(5)
+  %gep = getelementptr [8 x i8], ptr addrspace(5) %alloca, i32 %idx
----------------
shiltian wrote:

This is a modified test case based on a reduced version that can only be triggered by `amdgpu12.50-amd-amdhsa`. I don't want to add a new test case dedicated to `amdgpu12.50-amd-amdhsa`, so I modified the existing one to make sure it triggers the same assertion from the same bitcast creation.

https://github.com/llvm/llvm-project/pull/215933


More information about the llvm-commits mailing list