@@ -8342,6 +8342,14 @@ void EmitPass::emitAddrSpaceCast(llvm::AddrSpaceCastInst* addrSpaceCast)
8342
8342
unsigned sourceAddrSpace = addrSpaceCast->getSrcAddressSpace();
8343
8343
unsigned destAddrSpace = addrSpaceCast->getDestAddressSpace();
8344
8344
8345
+ if (srcV->IsImmediate() && srcV->GetImmediateValue() == 0x0)
8346
+ {
8347
+ // If casting from null, don't do tagging
8348
+ m_encoder->Cast(m_destination, srcV);
8349
+ m_encoder->Push();
8350
+ return;
8351
+ }
8352
+
8345
8353
if (destAddrSpace == ADDRESS_SPACE_GENERIC)
8346
8354
{
8347
8355
// Address space cast is in the form of {private, local, global} -> generic
@@ -8385,7 +8393,6 @@ void EmitPass::emitAddrSpaceCast(llvm::AddrSpaceCastInst* addrSpaceCast)
8385
8393
m_encoder->Copy(srcHigh, srcAlias);
8386
8394
m_encoder->Push();
8387
8395
8388
-
8389
8396
// Add tag to high part
8390
8397
m_encoder->Or(srcHigh, srcHigh, m_currShader->ImmToVariable(0x20000000, ISA_TYPE_UD));
8391
8398
m_encoder->Push();
@@ -8452,7 +8459,6 @@ void EmitPass::emitAddrSpaceCast(llvm::AddrSpaceCastInst* addrSpaceCast)
8452
8459
m_encoder->Copy(srcHigh, srcAlias);
8453
8460
m_encoder->Push();
8454
8461
8455
-
8456
8462
// Add tag to high part
8457
8463
m_encoder->Or(srcHigh, srcHigh, m_currShader->ImmToVariable(0x40000000, ISA_TYPE_UD));
8458
8464
m_encoder->Push();
@@ -8486,87 +8492,84 @@ void EmitPass::emitAddrSpaceCast(llvm::AddrSpaceCastInst* addrSpaceCast)
8486
8492
m_encoder->Push();
8487
8493
}
8488
8494
}
8489
- else // clear up the tag
8495
+ else if (sourceAddrSpace == ADDRESS_SPACE_GENERIC &&
8496
+ (destAddrSpace == ADDRESS_SPACE_PRIVATE || destAddrSpace == ADDRESS_SPACE_LOCAL))
8490
8497
{
8491
8498
// Address space cast is in the form of generic -> {private, local, global}
8492
8499
// Tag is removed according to the address space of the destination
8493
8500
8494
- if (destAddrSpace == ADDRESS_SPACE_PRIVATE || destAddrSpace == ADDRESS_SPACE_LOCAL )
8501
+ if (m_pCtx->m_hasEmu64BitInsts && m_currShader->m_Platform->hasNo64BitInst() )
8495
8502
{
8496
- if (m_pCtx->m_hasEmu64BitInsts && m_currShader->m_Platform->hasNo64BitInst() )
8503
+ if (m_currShader->GetContext()->getRegisterPointerSizeInBits(destAddrSpace) == 32 )
8497
8504
{
8498
- if (m_currShader->GetContext()->getRegisterPointerSizeInBits(destAddrSpace) == 32)
8499
- {
8500
- // Src
8501
- CVariable* srcAlias = m_currShader->GetNewAlias(srcV, ISA_TYPE_UD, 0, 0);
8502
- CVariable* srcLow = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8503
- ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8504
-
8505
- // Get low part of srcV
8506
- m_encoder->SetSrcSubReg(0, 0);
8507
- m_encoder->SetSrcRegion(0, 2, 1, 0);
8508
- m_encoder->Copy(srcLow, srcAlias);
8509
- m_encoder->Push();
8510
-
8511
- // Copy result to Dst
8512
- m_encoder->Cast(m_destination, srcLow);
8513
- m_encoder->Push();
8514
-
8515
- }
8516
- else
8517
- {
8518
- // Src
8519
- CVariable* srcAlias = m_currShader->GetNewAlias(srcV, ISA_TYPE_UD, 0, 0);
8520
- CVariable* srcLow = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8521
- ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8522
- CVariable* srcHigh = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8523
- ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8524
-
8525
- // Split Src into {Low, High}
8526
- // Low:
8527
- m_encoder->SetSrcSubReg(0, 0);
8528
- m_encoder->SetSrcRegion(0, 2, 1, 0);
8529
- m_encoder->Copy(srcLow, srcAlias);
8530
- m_encoder->Push();
8531
- // High:
8532
- m_encoder->SetSrcSubReg(0, 1);
8533
- m_encoder->SetSrcRegion(0, 2, 1, 0);
8534
- m_encoder->Copy(srcHigh, srcAlias);
8535
- m_encoder->Push();
8505
+ // Src
8506
+ CVariable* srcAlias = m_currShader->GetNewAlias(srcV, ISA_TYPE_UD, 0, 0);
8507
+ CVariable* srcLow = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8508
+ ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8536
8509
8537
- // Add tag to high part
8538
- m_encoder->And(srcHigh, srcHigh, m_currShader->ImmToVariable(0xFFFFFFF, ISA_TYPE_UD));
8539
- m_encoder->Push();
8510
+ // Get low part of srcV
8511
+ m_encoder->SetSrcSubReg(0, 0);
8512
+ m_encoder->SetSrcRegion(0, 2, 1, 0);
8513
+ m_encoder->Copy(srcLow, srcAlias);
8514
+ m_encoder->Push();
8540
8515
8541
- // Copy to Dst
8542
- CVariable* dstAlias = m_currShader->BitCast(m_destination, ISA_TYPE_UD);
8543
- // Low:
8544
- m_encoder->SetDstRegion(2);
8545
- m_encoder->Copy(dstAlias, srcLow);
8546
- m_encoder->Push();
8547
- // High:
8548
- m_encoder->SetDstSubReg(1);
8549
- m_encoder->SetDstRegion(2);
8550
- m_encoder->Copy(dstAlias, srcHigh);
8551
- m_encoder->Push();
8552
- }
8516
+ // Copy result to Dst
8517
+ m_encoder->Cast(m_destination, srcLow);
8518
+ m_encoder->Push();
8553
8519
}
8554
8520
else
8555
8521
{
8556
- CVariable* pTempVar = m_currShader->GetNewVariable(
8557
- numLanes(m_currShader->m_SIMDSize),
8558
- ISA_TYPE_UQ, m_currShader->getGRFAlignment(), m_destination->IsUniform());
8559
- m_encoder->And(pTempVar, srcV, m_currShader->ImmToVariable(0xFFFFFFFFFFFFFFF, ISA_TYPE_UQ));
8560
- m_encoder->Cast(m_destination, pTempVar);
8522
+ // Src
8523
+ CVariable* srcAlias = m_currShader->GetNewAlias(srcV, ISA_TYPE_UD, 0, 0);
8524
+ CVariable* srcLow = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8525
+ ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8526
+ CVariable* srcHigh = m_currShader->GetNewVariable(numLanes(m_currShader->m_SIMDSize),
8527
+ ISA_TYPE_UD, EALIGN_GRF, m_destination->IsUniform());
8528
+
8529
+ // Split Src into {Low, High}
8530
+ // Low:
8531
+ m_encoder->SetSrcSubReg(0, 0);
8532
+ m_encoder->SetSrcRegion(0, 2, 1, 0);
8533
+ m_encoder->Copy(srcLow, srcAlias);
8534
+ m_encoder->Push();
8535
+ // High:
8536
+ m_encoder->SetSrcSubReg(0, 1);
8537
+ m_encoder->SetSrcRegion(0, 2, 1, 0);
8538
+ m_encoder->Copy(srcHigh, srcAlias);
8539
+ m_encoder->Push();
8540
+
8541
+ // Add tag to high part
8542
+ m_encoder->And(srcHigh, srcHigh, m_currShader->ImmToVariable(0xFFFFFFF, ISA_TYPE_UD));
8543
+ m_encoder->Push();
8544
+
8545
+ // Copy to Dst
8546
+ CVariable* dstAlias = m_currShader->BitCast(m_destination, ISA_TYPE_UD);
8547
+ // Low:
8548
+ m_encoder->SetDstRegion(2);
8549
+ m_encoder->Copy(dstAlias, srcLow);
8550
+ m_encoder->Push();
8551
+ // High:
8552
+ m_encoder->SetDstSubReg(1);
8553
+ m_encoder->SetDstRegion(2);
8554
+ m_encoder->Copy(dstAlias, srcHigh);
8561
8555
m_encoder->Push();
8562
8556
}
8563
8557
}
8564
- else // ADDRESS_SPACE_GLOBAL
8558
+ else
8565
8559
{
8566
- m_encoder->Cast(m_destination, srcV);
8560
+ CVariable* pTempVar = m_currShader->GetNewVariable(
8561
+ numLanes(m_currShader->m_SIMDSize),
8562
+ ISA_TYPE_UQ, m_currShader->getGRFAlignment(), m_destination->IsUniform());
8563
+ m_encoder->And(pTempVar, srcV, m_currShader->ImmToVariable(0xFFFFFFFFFFFFFFF, ISA_TYPE_UQ));
8564
+ m_encoder->Cast(m_destination, pTempVar);
8567
8565
m_encoder->Push();
8568
8566
}
8569
8567
}
8568
+ else // ADDRESS_SPACE_GLOBAL
8569
+ {
8570
+ m_encoder->Cast(m_destination, srcV);
8571
+ m_encoder->Push();
8572
+ }
8570
8573
}
8571
8574
8572
8575
void EmitPass::emitExtract(llvm::Instruction* inst)
0 commit comments