[llvm] r192375 - R600: Fix trunc i64 to i32 on SI

Matt Arsenault Matthew.Arsenault at amd.com
Thu Oct 10 11:04:16 PDT 2013


Author: arsenm
Date: Thu Oct 10 13:04:16 2013
New Revision: 192375

URL: http://llvm.org/viewvc/llvm-project?rev=192375&view=rev
Log:
R600: Fix trunc i64 to i32 on SI

Modified:
    llvm/trunk/lib/Target/R600/SIInstructions.td
    llvm/trunk/test/CodeGen/R600/trunc.ll

Modified: llvm/trunk/lib/Target/R600/SIInstructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/R600/SIInstructions.td?rev=192375&r1=192374&r2=192375&view=diff
==============================================================================
--- llvm/trunk/lib/Target/R600/SIInstructions.td (original)
+++ llvm/trunk/lib/Target/R600/SIInstructions.td Thu Oct 10 13:04:16 2013
@@ -851,6 +851,11 @@ def : Pat <
   (V_CNDMASK_B32_e64 $src0, $src1, $src2)
 >;
 
+def : Pat <
+  (i32 (trunc i64:$val)),
+  (EXTRACT_SUBREG $val, sub0)
+>;
+
 //use two V_CNDMASK_B32_e64 instructions for f64
 def : Pat <
   (f64 (select i1:$src2, f64:$src1, f64:$src0)),

Modified: llvm/trunk/test/CodeGen/R600/trunc.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/R600/trunc.ll?rev=192375&r1=192374&r2=192375&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/R600/trunc.ll (original)
+++ llvm/trunk/test/CodeGen/R600/trunc.ll Thu Oct 10 13:04:16 2013
@@ -17,3 +17,15 @@ define void @trunc_i64_to_i32_store(i32
   ret void
 }
 
+; SI-LABEL: @trunc_shl_i64:
+; SI: S_LOAD_DWORDX2
+; SI: S_LOAD_DWORDX2 [[SREG:SGPR[0-9]+_SGPR[0-9]+]]
+; SI: V_LSHL_B64 [[LO_VREG:VGPR[0-9]+]]_VGPR{{[0-9]+}}, [[SREG]], 2
+; SI-NOT: [[LO_VREG]]
+; SI: BUFFER_STORE_DWORD [[LO_VREG]],
+define void @trunc_shl_i64(i32 addrspace(1)* %out, i64 %a) {
+  %b = shl i64 %a, 2
+  %result = trunc i64 %b to i32
+  store i32 %result, i32 addrspace(1)* %out, align 4
+  ret void
+}





More information about the llvm-commits mailing list