R600/SI: Don't promote f32 select to i32
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 12 Dec 2014 02:30:29 +0000 (02:30 +0000)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Fri, 12 Dec 2014 02:30:29 +0000 (02:30 +0000)
This is nice for the instruction patterns, but it complicates
min / max matching. The select doesn't have the correct type and would
require looking through the bitcasts for the real float operands.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224092 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/R600/SIISelLowering.cpp
lib/Target/R600/SIInstructions.td
test/CodeGen/R600/seto.ll
test/CodeGen/R600/setuo.ll
test/CodeGen/R600/sint_to_fp.ll
test/CodeGen/R600/uint_to_fp.ll

index f4acbf44111525a7e5573f5fc8f34b3677cf09ae..e41cad23de214370e62bcba3e5f363c4ab2cf29b 100644 (file)
@@ -93,8 +93,6 @@ SITargetLowering::SITargetLowering(TargetMachine &TM) :
   setOperationAction(ISD::STORE, MVT::v2i32, Custom);
   setOperationAction(ISD::STORE, MVT::v4i32, Custom);
 
-  setOperationAction(ISD::SELECT, MVT::f32, Promote);
-  AddPromotedToType(ISD::SELECT, MVT::f32, MVT::i32);
   setOperationAction(ISD::SELECT, MVT::i64, Custom);
   setOperationAction(ISD::SELECT, MVT::f64, Promote);
   AddPromotedToType(ISD::SELECT, MVT::f64, MVT::i64);
index eb7c98754f16563a44b690a88c980d7d99870b8b..aeba3518f7b8787da5e376a661e70cbc16c58f45 100644 (file)
@@ -3184,6 +3184,11 @@ def : Pat <
              (V_ALIGNBIT_B32 $a, $a, 8))
 >;
 
+def : Pat <
+  (f32 (select i1:$src2, f32:$src1, f32:$src0)),
+  (V_CNDMASK_B32_e64 $src0, $src1, $src2)
+>;
+
 //============================================================================//
 // Miscellaneous Optimization Patterns
 //============================================================================//
index 5fe6ff6bcd358eb1c412c684c0dde46699576bc0..634f35cb597623c5c9674fa50f11eb61f68d5c4f 100644 (file)
@@ -2,7 +2,7 @@
 
 ; CHECK-LABEL: {{^}}main:
 ; CHECK: v_cmp_o_f32_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], [[SREG:s[0-9]+]], [[SREG]]
-; CHECK-NEXT: v_cndmask_b32_e64 {{v[0-9]+}}, 0, 1.0, [[CMP]]
+; CHECK-NEXT: v_cndmask_b32_e64 {{v[0-9]+}}, 0.0, 1.0, [[CMP]]
 define void @main(float %p) {
 main_body:
   %c = fcmp oeq float %p, %p
index a3911777a9a6be41dd8ba2e5837f54f6da3f13bc..efa4e6c5ece0e16d0690624e8dd8a92855dff9c9 100644 (file)
@@ -2,7 +2,7 @@
 
 ; CHECK-LABEL: {{^}}main:
 ; CHECK: v_cmp_u_f32_e64 [[CMP:s\[[0-9]+:[0-9]+\]]], [[SREG:s[0-9]+]], [[SREG]]
-; CHECK-NEXT: v_cndmask_b32_e64 {{v[0-9]+}}, 0, 1.0, [[CMP]]
+; CHECK-NEXT: v_cndmask_b32_e64 {{v[0-9]+}}, 0.0, 1.0, [[CMP]]
 define void @main(float %p) {
 main_body:
   %c = fcmp une float %p, %p
index 7b6ce43e30429c0bbc0f04ce1399063dfad1277a..1d10487c351dbb3c7cb6854da0de366237a6e2b4 100644 (file)
@@ -42,7 +42,7 @@ define void @sint_to_fp_v4i32(<4 x float> addrspace(1)* %out, <4 x i32> addrspac
 
 ; FUNC-LABEL: {{^}}sint_to_fp_i1_f32:
 ; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
-; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0, [[CMP]]
+; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0.0, 1.0, [[CMP]]
 ; SI: buffer_store_dword [[RESULT]],
 ; SI: s_endpgm
 define void @sint_to_fp_i1_f32(float addrspace(1)* %out, i32 %in) {
index f3bc62a488300ef12dde7e62c907961f5aa76ca7..a7692accd53c99cb3916fedcfea2b839afc7ac0e 100644 (file)
@@ -60,7 +60,7 @@ entry:
 
 ; FUNC-LABEL: {{^}}uint_to_fp_i1_to_f32:
 ; SI: v_cmp_eq_i32_e64 [[CMP:s\[[0-9]+:[0-9]\]]],
-; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0, 1.0, [[CMP]]
+; SI-NEXT: v_cndmask_b32_e64 [[RESULT:v[0-9]+]], 0.0, 1.0, [[CMP]]
 ; SI: buffer_store_dword [[RESULT]],
 ; SI: s_endpgm
 define void @uint_to_fp_i1_to_f32(float addrspace(1)* %out, i32 %in) {