@@ -1767,7 +1767,6 @@ void ConstantCoalescing::ScatterToSampler(Instruction *load, Value *bufIdxV, uin
1767
1767
IGC_ASSERT ((!load->getType ()->isVectorTy ()) ||
1768
1768
(cast<IGCLLVM::FixedVectorType>(load->getType ())->getNumElements () <= 4 ));
1769
1769
1770
- const bool useByteAddress = m_ctx->m_DriverInfo .UsesTypedConstantBuffersWithByteAddress ();
1771
1770
1772
1771
// Code below doesn't support crossing 4 DWORD boundary i.e. mapping a
1773
1772
// single input load to multiple sampler loads.
@@ -1780,33 +1779,28 @@ void ConstantCoalescing::ScatterToSampler(Instruction *load, Value *bufIdxV, uin
1780
1779
irBuilder->SetInsertPoint (baseInBytes);
1781
1780
1782
1781
WIAnalysis::WIDependancy baseInBytesDep = wiAns->whichDepend (baseInBytes);
1782
+ Value *baseAddressInOwords = GetSamplerAlignedAddress (baseInBytes);
1783
+ IGC_ASSERT (baseAddressInOwords);
1784
+
1785
+ // it is possible that baseInBytes is uniform, yet load is non-uniform due to the use location of load
1786
+ if (baseAddressInOwords != baseInBytes->getOperand (0 )) {
1787
+ Value *newVal = irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 4 ));
1788
+ wiAns->incUpdateDepend (newVal, baseInBytesDep);
1789
+ baseInBytes->replaceAllUsesWith (newVal);
1790
+ } else if (wiAns->whichDepend (baseAddressInOwords) != baseInBytesDep) {
1791
+ // quick fix for a special case: baseAddressInOwords is uniform and baseInBytes is not uniform.
1792
+ // If we use baseInBytes-src0 (elementIndx) directly at cf-join point by this transform,
1793
+ // we can change the uniformness of baseAddressInOwords
1794
+ baseAddressInOwords =
1795
+ irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 0 ));
1796
+ wiAns->incUpdateDepend (baseAddressInOwords, baseInBytesDep);
1797
+ Value *newVal = irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 4 ));
1798
+ wiAns->incUpdateDepend (newVal, baseInBytesDep);
1799
+ baseInBytes->replaceAllUsesWith (newVal);
1800
+ }
1801
+
1802
+ Value *chunkBaseAddress = baseAddressInOwords;
1783
1803
1784
- // Data address for sampler load, either in OWORDs or in bytes
1785
- Value *chunkBaseAddress = baseInBytes;
1786
- if (!useByteAddress) {
1787
- // base address is in OWORDs
1788
- Value *baseAddressInOwords = GetSamplerAlignedAddress (baseInBytes);
1789
- IGC_ASSERT (baseAddressInOwords);
1790
-
1791
- // it is possible that baseInBytes is uniform, yet load is non-uniform due to the use location of load
1792
- if (baseAddressInOwords != baseInBytes->getOperand (0 )) {
1793
- Value *newVal = irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 4 ));
1794
- wiAns->incUpdateDepend (newVal, baseInBytesDep);
1795
- baseInBytes->replaceAllUsesWith (newVal);
1796
- } else if (wiAns->whichDepend (baseAddressInOwords) != baseInBytesDep) {
1797
- // quick fix for a special case: baseAddressInOwords is uniform and baseInBytes is not uniform.
1798
- // If we use baseInBytes-src0 (elementIndx) directly at cf-join point by this transform,
1799
- // we can change the uniformness of baseAddressInOwords
1800
- baseAddressInOwords =
1801
- irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 0 ));
1802
- wiAns->incUpdateDepend (baseAddressInOwords, baseInBytesDep);
1803
- Value *newVal = irBuilder->CreateShl (baseAddressInOwords, ConstantInt::get (baseAddressInOwords->getType (), 4 ));
1804
- wiAns->incUpdateDepend (newVal, baseInBytesDep);
1805
- baseInBytes->replaceAllUsesWith (newVal);
1806
- }
1807
-
1808
- chunkBaseAddress = baseAddressInOwords;
1809
- }
1810
1804
BufChunk *cov_chunk = nullptr ;
1811
1805
for (std::vector<BufChunk *>::reverse_iterator rit = chunk_vec.rbegin (), rie = chunk_vec.rend (); rit != rie;
1812
1806
++rit) {
@@ -1836,12 +1830,11 @@ void ConstantCoalescing::ScatterToSampler(Instruction *load, Value *bufIdxV, uin
1836
1830
1837
1831
Value *dataAddress = chunkBaseAddress;
1838
1832
if (offsetInBytes >= samplerLoadSizeInBytes) {
1839
- const uint32_t chunkOffset = (useByteAddress) ? (cov_chunk->chunkStart * cov_chunk->elementSize ) : // in bytes
1840
- (offsetInBytes / samplerLoadSizeInBytes); // in OWORDs
1833
+ const uint32_t chunkOffset = offsetInBytes / samplerLoadSizeInBytes;
1841
1834
dataAddress = irBuilder->CreateAdd (dataAddress, ConstantInt::get (dataAddress->getType (), chunkOffset));
1842
1835
wiAns->incUpdateDepend (dataAddress, WIAnalysis::RANDOM);
1843
1836
}
1844
- if (dataAddress->getType ()->getIntegerBitWidth () >= 32 && !useByteAddress ) {
1837
+ if (dataAddress->getType ()->getIntegerBitWidth () >= 32 ) {
1845
1838
dataAddress = irBuilder->CreateAnd (dataAddress, ConstantInt::get (dataAddress->getType (), 0x0FFFFFFF ));
1846
1839
wiAns->incUpdateDepend (dataAddress, WIAnalysis::RANDOM);
1847
1840
}
0 commit comments