Skip to content

Commit

Permalink
AMDGPU: Fix v2i64<->v4f32 bitcast
Browse files Browse the repository at this point in the history
I'm not sure how to test the v2i64->v4f32 case since I can't think of
any v2i64 cases that won't legalize to v4i32.
  • Loading branch information
arsenm committed Feb 20, 2020
1 parent 15e20dc commit 083717c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/SIInstructions.td
Expand Up @@ -1123,6 +1123,8 @@ def : BitConvert <v4f32, v2f64, VReg_128>;
def : BitConvert <v4i32, v2f64, VReg_128>;
def : BitConvert <v2i64, v2f64, VReg_128>;
def : BitConvert <v2f64, v2i64, VReg_128>;
def : BitConvert <v4f32, v2i64, VReg_128>;
def : BitConvert <v2i64, v4f32, VReg_128>;

// 160-bit bitcast
def : BitConvert <v5i32, v5f32, SGPR_160>;
Expand Down
11 changes: 11 additions & 0 deletions llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll
Expand Up @@ -287,3 +287,14 @@ define amdgpu_kernel void @v2i32_to_v4f16(<4 x half> addrspace(1)* %out, <2 x i3
store <4 x half> %add.bitcast, <4 x half> addrspace(1)* %out
ret void
}

declare <4 x float> @llvm.amdgcn.s.buffer.load.v4f32(<4 x i32>, i32, i32 immarg)

; FUNC-LABEL: {{^}}bitcast_v4f32_to_v2i64:
; GCN: s_buffer_load_dwordx4
define <2 x i64> @bitcast_v4f32_to_v2i64(<2 x i64> %arg) {
%val = call <4 x float> @llvm.amdgcn.s.buffer.load.v4f32(<4 x i32> undef, i32 0, i32 0)
%cast = bitcast <4 x float> %val to <2 x i64>
%div = udiv <2 x i64> %cast, %arg
ret <2 x i64> %div
}

0 comments on commit 083717c

Please sign in to comment.