| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py |
| ; RUN: opt -S -mtriple=amdgpu9.00-amd-amdhsa -passes=amdgpu-promote-alloca,verify < %s | FileCheck %s |
| |
| ; Promoting these allocas to a byte vector forces a conversion between a |
| ; byte-vector and a pointer of the same size. Byte types are not integers, so |
| ; before CreateBitPreservingCastChain learned to treat them like integers this |
| ; produced a direct (and invalid) `bitcast <2 x b32> to ptr`, which later |
| ; tripped the MachineVerifier ("bitcast cannot convert between pointers and |
| ; other types"). The conversion must instead route through a pointer-sized |
| ; integer via inttoptr/ptrtoint. |
| |
| target datalayout = "e-p:64:64-p5:32:32-A5" |
| |
| define amdgpu_kernel void @ptr_from_byte_vec(ptr %out, ptr %inptr) { |
| ; CHECK-LABEL: @ptr_from_byte_vec( |
| ; CHECK-NEXT: entry: |
| ; CHECK-NEXT: [[A:%.*]] = freeze <2 x b32> poison |
| ; CHECK-NEXT: [[PBITS:%.*]] = load b64, ptr [[INPTR:%.*]], align 8 |
| ; CHECK-NEXT: [[TMP0:%.*]] = bitcast b64 [[PBITS]] to <2 x b32> |
| ; CHECK-NEXT: [[TMP1:%.*]] = bitcast <2 x b32> [[TMP0]] to i64 |
| ; CHECK-NEXT: [[TMP2:%.*]] = inttoptr i64 [[TMP1]] to ptr |
| ; CHECK-NEXT: store ptr [[TMP2]], ptr [[OUT:%.*]], align 8 |
| ; CHECK-NEXT: ret void |
| ; |
| entry: |
| %a = alloca [2 x b32], align 8, addrspace(5) |
| %pbits = load b64, ptr %inptr, align 8 |
| store b64 %pbits, ptr addrspace(5) %a, align 8 |
| %p = load ptr, ptr addrspace(5) %a, align 8 |
| store ptr %p, ptr %out, align 8 |
| ret void |
| } |
| |
| define amdgpu_kernel void @byte_vec_from_ptr(ptr %out, ptr %argp) { |
| ; CHECK-LABEL: @byte_vec_from_ptr( |
| ; CHECK-NEXT: entry: |
| ; CHECK-NEXT: [[A:%.*]] = freeze <2 x b32> poison |
| ; CHECK-NEXT: [[TMP0:%.*]] = ptrtoint ptr [[ARGP:%.*]] to i64 |
| ; CHECK-NEXT: [[TMP1:%.*]] = bitcast i64 [[TMP0]] to <2 x b32> |
| ; CHECK-NEXT: store <2 x b32> [[TMP1]], ptr [[OUT:%.*]], align 8 |
| ; CHECK-NEXT: ret void |
| ; |
| entry: |
| %a = alloca [2 x b32], align 8, addrspace(5) |
| store ptr %argp, ptr addrspace(5) %a, align 8 |
| %v = load <2 x b32>, ptr addrspace(5) %a, align 8 |
| store <2 x b32> %v, ptr %out, align 8 |
| ret void |
| } |