swr/rast: Replace VPSRL with LSHR
authorTim Rowley <timothy.o.rowley@intel.com>
Tue, 12 Dec 2017 20:23:50 +0000 (14:23 -0600)
committerTim Rowley <timothy.o.rowley@intel.com>
Fri, 15 Dec 2017 16:56:54 +0000 (10:56 -0600)
Replace use of x86 intrinsic with general llvm IR instruction.

Generates the same final assembly.

Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_ir_macros.py
src/gallium/drivers/swr/rasterizer/jitter/builder_misc.cpp
src/gallium/drivers/swr/rasterizer/jitter/builder_misc.h
src/gallium/drivers/swr/rasterizer/jitter/fetch_jit.cpp

index 8bbf36d9b83cd6ede8419c2a3574cdd9f5cb5252..9544353eb97ee4634be85c546b7d450048af9f51 100644 (file)
@@ -47,8 +47,6 @@ intrinsics = [
         ['VGATHERPS_16', 'x86_avx512_gather_dps_512', ['src', 'pBase', 'indices', 'mask', 'scale']],
         ['VGATHERDD', 'x86_avx2_gather_d_d_256', ['src', 'pBase', 'indices', 'mask', 'scale']],
         ['VGATHERDD_16', 'x86_avx512_gather_dpi_512', ['src', 'pBase', 'indices', 'mask', 'scale']],
-        ['VPSRLI', 'x86_avx2_psrli_d', ['src', 'imm']],
-        ['VPSRLI_16', 'x86_avx512_psrli_d_512', ['src', 'imm']],
         ['VSQRTPS', 'x86_avx_sqrt_ps_256', ['a']],
         ['VRSQRTPS', 'x86_avx_rsqrt_ps_256', ['a']],
         ['VRCPPS', 'x86_avx_rcp_ps_256', ['a']],
index 684c9fac549a687b1cb8cdc6bc7c746e6d0e33e5..bdcafd28a39af7e08d1cf467d8aa0b75e06b55be 100644 (file)
@@ -808,36 +808,6 @@ namespace SwrJit
         return vGather;
     }
 
-#if USE_SIMD16_BUILDER
-    Value *Builder::PSRLI(Value *a, Value *imm)
-    {
-        return VPSRLI(a, imm);
-    }
-
-    Value *Builder::PSRLI_16(Value *a, Value *imm)
-    {
-        Value *result = VUNDEF2_I();
-
-        // use avx512 shift right instruction if available
-        if (JM()->mArch.AVX512F())
-        {
-            result = VPSRLI_16(a, imm);
-        }
-        else
-        {
-            Value *a0 = EXTRACT2_I(a, 0);
-            Value *a1 = EXTRACT2_I(a, 1);
-
-            Value *result0 = PSRLI(a0, imm);
-            Value *result1 = PSRLI(a1, imm);
-
-            result = JOIN2(result0, result1);
-        }
-
-        return result;
-    }
-
-#endif
 #if USE_SIMD16_BUILDER
     //////////////////////////////////////////////////////////////////////////
     /// @brief
index 6c883d8f52b971ff7bdc19a797c5d298d55ce228..98bc56335123c4338fa84001db4ae4c2ead723a7 100644 (file)
@@ -143,11 +143,6 @@ void GATHER4DD(const SWR_FORMAT_INFO &info, Value* pSrcBase, Value* byteOffsets,
 
 Value *GATHERPD(Value* src, Value* pBase, Value* indices, Value* mask, uint8_t scale = 1);
 
-#if USE_SIMD16_BUILDER
-Value *PSRLI(Value *a, Value *imm);
-Value *PSRLI_16(Value *a, Value *imm);
-
-#endif
 void SCATTERPS(Value* pDst, Value* vSrc, Value* vOffsets, Value* vMask);
 
 void Shuffle8bpcGather4(const SWR_FORMAT_INFO &info, Value* vGatherInput, Value* vGatherOutput[], bool bPackedOutput);
index 1312ac000936603b2df90ee831e2e3f8d9095a7c..8d97ddfdc9846e251ac0f76fa3b5a498d4b5792f 100644 (file)
@@ -1422,12 +1422,12 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE &fetchState,
                                 // But, we know that elements must be aligned for FETCH. :)
                                 // Right shift the offset by a bit and then scale by 2 to remove the sign extension.
 #if USE_SIMD16_BUILDER
-                                Value *shiftedOffsets = VPSRLI_16(vOffsets16, C(1));
+                                Value *shiftedOffsets = LSHR(vOffsets16, 1);
                                 pVtxSrc2[currentVertexElement] = GATHERPS_16(gatherSrc16, pStreamBase, shiftedOffsets, vGatherMask16, 2);
 
 #else
-                                Value *vShiftedOffsets = VPSRLI(vOffsets, C(1));
-                                Value *vShiftedOffsets2 = VPSRLI(vOffsets2, C(1));
+                                Value *vShiftedOffsets = LSHR(vOffsets, 1);
+                                Value *vShiftedOffsets2 = LSHR(vOffsets2, 1);
 
                                 vVertexElements[currentVertexElement]  = GATHERPS(gatherSrc, pStreamBase, vShiftedOffsets, vGatherMask, 2);
                                 vVertexElements2[currentVertexElement] = GATHERPS(gatherSrc2, pStreamBase, vShiftedOffsets2, vGatherMask2, 2);
@@ -1492,7 +1492,7 @@ void FetchJit::JitGatherVertices(const FETCH_COMPILE_STATE &fetchState,
                                 // However, GATHERPS uses signed 32-bit offsets, so only a 2GB range :(
                                 // But, we know that elements must be aligned for FETCH. :)
                                 // Right shift the offset by a bit and then scale by 2 to remove the sign extension.
-                                Value* vShiftedOffsets = VPSRLI(vOffsets, C(1));
+                                Value* vShiftedOffsets = LSHR(vOffsets, 1);
                                 vVertexElements[currentVertexElement++] = GATHERPS(gatherSrc, pStreamBase, vShiftedOffsets, vGatherMask, 2);
                             }
                             else