swr/rast: Use llvm intrinsic masked gather
authorGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 2 Feb 2018 23:03:01 +0000 (17:03 -0600)
committerGeorge Kyriazis <george.kyriazis@intel.com>
Fri, 16 Feb 2018 16:54:01 +0000 (10:54 -0600)
Use llvm intrinsic masked.gather instead of manual unroll for the cases
where we have vector of pointers.  Improves llvm IR debug experience by
reducing a ton of IR to a single intrinsic call. Also seems to reduce
overall stack use considerably.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/jitter/builder_mem.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_mem.h

index 6e462d522f7551aca28d7f2147415b7ffb015539..86fdfca392fa832d834b9a3f334d4a97214d101e 100644 (file)
@@ -346,6 +346,18 @@ namespace SwrJit
         return vGather;
     }
 
+    //////////////////////////////////////////////////////////////////////////
+    /// @brief Alternative masked gather where source is a vector of pointers
+    /// @param pVecSrcPtr   - SIMD wide vector of pointers
+    /// @param pVecMask     - SIMD active lanes
+    /// @param pVecPassthru - SIMD wide vector of values to load when lane is inactive
+    Value* Builder::GATHER_PTR(Value* pVecSrcPtr, Value* pVecMask, Value* pVecPassthru)
+    {
+        Function* pMaskedGather = llvm::Intrinsic::getDeclaration(JM()->mpCurrentModule, Intrinsic::masked_gather, { pVecPassthru->getType() });
+
+        return CALL(pMaskedGather, { pVecSrcPtr, C(0), pVecMask, pVecPassthru });
+    }
+
     void Builder::Gather4(const SWR_FORMAT format, Value* pSrcBase, Value* byteOffsets,
         Value* mask, Value* vGatherComponents[], bool bPackedOutput)
     {
index c2279a62d9891093c6158595dd3f73ae63db2da4..f31cb4abae08f9a7af5d168479b9882cb78a7240 100644 (file)
@@ -58,6 +58,8 @@ virtual void GATHER4DD(const SWR_FORMAT_INFO &info, Value* pSrcBase, Value* byte
 
 Value *GATHERPD(Value* src, Value* pBase, Value* indices, Value* mask, uint8_t scale = 1);
 
+Value *GATHER_PTR(Value* pVecSrcPtr, Value* pVecMask, Value* pVecPassthru);
+
 void SCATTERPS(Value* pDst, Value* vSrc, Value* vOffsets, Value* vMask);
 
 void Shuffle8bpcGather4(const SWR_FORMAT_INFO &info, Value* vGatherInput, Value* vGatherOutput[], bool bPackedOutput);