[llvm] 083717c - AMDGPU: Fix v2i64<->v4f32 bitcast

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 20 06:49:27 PST 2020


Author: Matt Arsenault
Date: 2020-02-20T09:49:09-05:00
New Revision: 083717cf49968ebb973d73b448709d45e3fc0e99

URL: https://github.com/llvm/llvm-project/commit/083717cf49968ebb973d73b448709d45e3fc0e99
DIFF: https://github.com/llvm/llvm-project/commit/083717cf49968ebb973d73b448709d45e3fc0e99.diff

LOG: AMDGPU: Fix v2i64<->v4f32 bitcast

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.

Added: 
    

Modified: 
    llvm/lib/Target/AMDGPU/SIInstructions.td
    llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/SIInstructions.td b/llvm/lib/Target/AMDGPU/SIInstructions.td
index c7837748ebd6..380b6dd7a6e7 100644
--- a/llvm/lib/Target/AMDGPU/SIInstructions.td
+++ b/llvm/lib/Target/AMDGPU/SIInstructions.td
@@ -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>;

diff  --git a/llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll b/llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll
index 8afe401746bb..ce1b7ef01f82 100644
--- a/llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll
+++ b/llvm/test/CodeGen/AMDGPU/amdgcn.bitcast.ll
@@ -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
+}


        


More information about the llvm-commits mailing list