R600/SI: Add pattern for truncating i32 to i1
authorMichel Danzer <michel.daenzer@amd.com>
Tue, 28 Jan 2014 03:01:16 +0000 (03:01 +0000)
committerMichel Danzer <michel.daenzer@amd.com>
Tue, 28 Jan 2014 03:01:16 +0000 (03:01 +0000)
Fixes half a dozen piglit tests with radeonsi.

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200283 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SIInstructions.td
test/CodeGen/R600/trunc.ll

index a38121bebd128b6d80c97a09df2c30863d20ccaf..912b59a9e7be44ebc7fd8793f6d6e6f177b90cd2 100644 (file)
@@ -2126,6 +2126,11 @@ def : Pat <
   (EXTRACT_SUBREG $a, sub0)
 >;
 
+def : Pat <
+  (i1 (trunc i32:$a)),
+  (V_CMP_EQ_I32_e64 (V_AND_B32_e32 (i32 1), $a), 1)
+>;
+
 // V_ADD_I32_e32/S_ADD_I32 produces carry in VCC/SCC. For the vector
 // case, the sgpr-copies pass will fix this to use the vector version.
 def : Pat <
index 0bd320ad9ceb1618f355337b34beb319cada7cfb..6bbd7f7b510e101cd0065393c5969a3d8a412189 100644 (file)
@@ -28,3 +28,13 @@ define void @trunc_shl_i64(i32 addrspace(1)* %out, i64 %a) {
   store i32 %result, i32 addrspace(1)* %out, align 4
   ret void
 }
+
+; SI-LABEL: @trunc_i32_to_i1:
+; SI: V_AND_B32
+; SI: V_CMP_EQ_I32
+define void @trunc_i32_to_i1(i32 addrspace(1)* %out, i32 %a) {
+  %trunc = trunc i32 %a to i1
+  %result = select i1 %trunc, i32 1, i32 0
+  store i32 %result, i32 addrspace(1)* %out, align 4
+  ret void
+}