[PATCH] D25805: [AMDGPU] Perform uchar to float combine for ISD::SINT_TO_FP

Konstantin Zhuravlyov via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 21 10:46:18 PDT 2016


kzhuravl updated this revision to Diff 75449.
kzhuravl added a comment.

Use getZExtOrTrunc


https://reviews.llvm.org/D25805

Files:
  lib/Target/AMDGPU/SIISelLowering.cpp


Index: lib/Target/AMDGPU/SIISelLowering.cpp
===================================================================
--- lib/Target/AMDGPU/SIISelLowering.cpp
+++ lib/Target/AMDGPU/SIISelLowering.cpp
@@ -233,6 +233,7 @@
   setTargetDAGCombine(ISD::AND);
   setTargetDAGCombine(ISD::OR);
   setTargetDAGCombine(ISD::XOR);
+  setTargetDAGCombine(ISD::SINT_TO_FP);
   setTargetDAGCombine(ISD::UINT_TO_FP);
   setTargetDAGCombine(ISD::FCANONICALIZE);
 
@@ -3521,18 +3522,25 @@
   case AMDGPUISD::CVT_F32_UBYTE3: {
     unsigned Offset = N->getOpcode() - AMDGPUISD::CVT_F32_UBYTE0;
     SDValue Src = N->getOperand(0);
+    if (Src.getOpcode() == ISD::ZERO_EXTEND &&
+        Src.getOperand(0).getOpcode() == ISD::SRL)
+      Src = Src.getOperand(0);
 
     // TODO: Handle (or x, (srl y, 8)) pattern when known bits are zero.
     if (Src.getOpcode() == ISD::SRL) {
       // cvt_f32_ubyte0 (srl x, 16) -> cvt_f32_ubyte2 x
       // cvt_f32_ubyte1 (srl x, 16) -> cvt_f32_ubyte3 x
       // cvt_f32_ubyte0 (srl x, 8) -> cvt_f32_ubyte1 x
 
       if (const ConstantSDNode *C = dyn_cast<ConstantSDNode>(Src.getOperand(1))) {
+        SDValue SrcZExt = DAG.getZExtOrTrunc(Src.getOperand(0),
+                                             SDLoc(Src.getOperand(0)),
+                                             EVT(MVT::i32));
+
         unsigned SrcOffset = C->getZExtValue() + 8 * Offset;
         if (SrcOffset < 32 && SrcOffset % 8 == 0) {
           return DAG.getNode(AMDGPUISD::CVT_F32_UBYTE0 + SrcOffset / 8, DL,
-                             MVT::f32, Src.getOperand(0));
+                             MVT::f32, SrcZExt);
         }
       }
     }
@@ -3550,7 +3558,7 @@
 
     break;
   }
-
+  case ISD::SINT_TO_FP:
   case ISD::UINT_TO_FP: {
     return performUCharToFloatCombine(N, DCI);
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25805.75449.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161021/f3069311/attachment.bin>


More information about the llvm-commits mailing list