Skip to content

Commit 80dd72a

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: f47f21f: Unification of pattern matching for imm global offset
This change is to unify the pattern matching case for imm global offset used in different functions. Moreover, this supports extra patterns with subtractionss in experimental code paths and resolves an issue with the immediate offsets in existing one.
1 parent 9a7edea commit 80dd72a

File tree

7 files changed

+108
-299
lines changed

7 files changed

+108
-299
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 39 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -737,8 +737,9 @@ bool EmitPass::runOnFunction(llvm::Function &F) {
737737
m_encoder->SetIsCodePatchCandidate(false);
738738
}
739739

740-
if (m_pCtx->platform.supportDualSimd8PS() && m_pCtx->platform.isCoreChildOf(IGFX_XE2_HPG_CORE) &&
741-
m_currShader->GetShaderType() == ShaderType::PIXEL_SHADER) {
740+
if (m_pCtx->platform.supportDualSimd8PS() &&
741+
m_pCtx->platform.isCoreChildOf(IGFX_XE2_HPG_CORE) &&
742+
m_currShader->GetShaderType() == ShaderType::PIXEL_SHADER ) {
742743
m_encoder->SetIsCodePatchCandidate(false);
743744
}
744745
} else {
@@ -3991,8 +3992,7 @@ void EmitPass::emitVideoAnalyticGRF(llvm::GenIntrinsicInst *inst, const DWORD re
39913992

39923993
static bool isVectorTypeAllowed(Value *I) {
39933994
IGCLLVM::FixedVectorType *VecType = llvm::dyn_cast<IGCLLVM::FixedVectorType>(I->getType());
3994-
if (!VecType)
3995-
return false;
3995+
if (!VecType) return false;
39963996
auto ElType = VecType->getElementType();
39973997
return ElType->isIntegerTy(32) || ElType->isFloatTy();
39983998
}
@@ -4038,10 +4038,8 @@ void EmitPass::BinaryUnary(llvm::Instruction *inst, const SSource source[2], con
40384038
break;
40394039
case Instruction::FAdd:
40404040
case Instruction::Add:
4041-
if (inst->getType()->isVectorTy())
4042-
Add(source, modifier);
4043-
else
4044-
EmitSimpleAlu(inst, source, modifier);
4041+
if (inst->getType()->isVectorTy()) Add(source, modifier);
4042+
else EmitSimpleAlu(inst, source, modifier);
40454043
break;
40464044
case Instruction::Call:
40474045
EmitAluIntrinsic(cast<CallInst>(inst), source, modifier);
@@ -4240,6 +4238,7 @@ static unsigned getVectorSize(Value *I) {
42404238
return NumElements;
42414239
}
42424240

4241+
42434242
void EmitPass::FPTrunc(const SSource sources[2], const DstModifier &modifier) {
42444243

42454244
CVariable *src[2];
@@ -4345,18 +4344,13 @@ bool EmitPass::isVectorEmissionPossible(const SSource sources[2], CVariable *src
43454344
// any non ordinary state of source modifiers
43464345
// can be a sign of emission of a specific pattern,
43474346
// emission can interfere with
4348-
if (sources[0].elementOffset != 0)
4349-
return false;
4350-
if (sources[1].elementOffset != 0)
4351-
return false;
4352-
if (sources[0].SIMDOffset != 0)
4353-
return false;
4354-
if (sources[1].SIMDOffset != 0)
4355-
return false;
4347+
if (sources[0].elementOffset != 0) return false;
4348+
if (sources[1].elementOffset != 0) return false;
4349+
if (sources[0].SIMDOffset != 0) return false;
4350+
if (sources[1].SIMDOffset != 0) return false;
43564351

43574352
bool AllowedVectorTypes = isVectorTypeAllowed(sources[0].value) && isVectorTypeAllowed(sources[1].value);
4358-
if (!AllowedVectorTypes)
4359-
return false;
4353+
if (!AllowedVectorTypes) return false;
43604354

43614355
bool DestSizeEquals = false;
43624356
// it's possible have a case where two uniform vectors are
@@ -4731,8 +4725,7 @@ void EmitPass::VectorMad(const SSource sources[3], const DstModifier &modifier)
47314725
void EmitPass::FDiv(const SSource sources[2], const DstModifier &modifier) {
47324726

47334727
CVariable *src[2];
4734-
for (int i = 0; i < 2; ++i)
4735-
src[i] = GetSrcVariable(sources[i]);
4728+
for (int i = 0; i < 2; ++i) src[i] = GetSrcVariable(sources[i]);
47364729
bool IsPossible = isVectorEmissionPossible(sources, src);
47374730

47384731
if (IGC_IS_FLAG_ENABLED(EnableVectorEmitter) && IsPossible) {
@@ -5697,7 +5690,8 @@ void EmitPass::emitSimdShuffle(llvm::Instruction *inst) {
56975690
CVariable *tempCopy = m_currShader->GetNewVariable(simdChannel, "SanitizedIndexShuffleTmp");
56985691
m_encoder->And(tempCopy, simdChannel, m_currShader->ImmToVariable(maskOfValidLanes, ISA_TYPE_UW));
56995692
simdChannelUW = m_currShader->BitCast(tempCopy, ISA_TYPE_UW);
5700-
} else {
5693+
}
5694+
else {
57015695
m_encoder->SetSrcRegion(0, 2, 1, 0);
57025696
m_encoder->SetDstRegion(2);
57035697
m_encoder->And(simdChannelUW, simdChannelUW, m_currShader->ImmToVariable(maskOfValidLanes, ISA_TYPE_UW));
@@ -8746,13 +8740,12 @@ void EmitPass::EmitGenIntrinsicMessage(llvm::GenIntrinsicInst *inst) {
87468740
break;
87478741
case GenISAIntrinsic::GenISA_ldrawvector_indexed:
87488742
case GenISAIntrinsic::GenISA_ldraw_indexed:
8749-
emitLoadRawIndexed(cast<LdRawIntrinsic>(inst), cast<LdRawIntrinsic>(inst)->getOffsetValue(), nullptr, nullptr,
8750-
false /*flipVarOffsetSign*/);
8743+
emitLoadRawIndexed(cast<LdRawIntrinsic>(inst), cast<LdRawIntrinsic>(inst)->getOffsetValue(), nullptr, nullptr);
87518744
break;
87528745
case GenISAIntrinsic::GenISA_storerawvector_indexed:
87538746
case GenISAIntrinsic::GenISA_storeraw_indexed:
87548747
emitStoreRawIndexed(cast<StoreRawIntrinsic>(inst), cast<StoreRawIntrinsic>(inst)->getOffsetValue(), nullptr,
8755-
nullptr, false /*flipVarOffsetSign*/);
8748+
nullptr);
87568749
break;
87578750
case GenISAIntrinsic::GenISA_GetBufferPtr:
87588751
emitGetBufferPtr(inst);
@@ -9218,7 +9211,6 @@ void EmitPass::EmitIntrinsicMessage(llvm::IntrinsicInst *inst) {
92189211
case Intrinsic::fabs:
92199212
case Intrinsic::trap:
92209213
case Intrinsic::experimental_noalias_scope_decl:
9221-
case Intrinsic::assume:
92229214
// do nothing
92239215
break;
92249216
case Intrinsic::stacksave:
@@ -10440,8 +10432,8 @@ void EmitPass::setRovCacheCtrl(GenIntrinsicInst *inst) {
1044010432
inst->setMetadata("lsc.cache.ctrl", node);
1044110433
}
1044210434

10443-
void EmitPass::emitLoadRawIndexed(LdRawIntrinsic *inst, Value *varOffset, ConstantInt *immScale, ConstantInt *immOffset,
10444-
bool flipVarOffsetSign) {
10435+
void EmitPass::emitLoadRawIndexed(LdRawIntrinsic *inst, Value *varOffset, ConstantInt *immScale,
10436+
ConstantInt *immOffset) {
1044510437
Value *bufPtrv = inst->getResourceValue();
1044610438

1044710439
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
@@ -10452,7 +10444,7 @@ void EmitPass::emitLoadRawIndexed(LdRawIntrinsic *inst, Value *varOffset, Consta
1045210444
}
1045310445
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromMetadata(inst, true);
1045410446
emitLSCVectorLoad(inst, bufPtrv,
10455-
varOffset, immOffset, immScale, flipVarOffsetSign, cacheOpts, addrSpace
10447+
varOffset, immOffset, immScale, cacheOpts, addrSpace
1045610448
);
1045710449
return;
1045810450
}
@@ -10711,8 +10703,7 @@ void EmitPass::emitLoad3DInner(LdRawIntrinsic *inst, ResourceDescriptor &resourc
1071110703
}
1071210704
}
1071310705

10714-
void EmitPass::emitLoad(LoadInst *inst, Value *offset, ConstantInt *immOffset, ConstantInt *immScale,
10715-
bool flipVarOffsetSign
10706+
void EmitPass::emitLoad(LoadInst *inst, Value *offset, ConstantInt *immOffset, ConstantInt *immScale
1071610707
) {
1071710708
if (m_pCtx->getModuleMetaData()->isHDCFastClearShader) {
1071810709
emitFastClear(inst);
@@ -10724,13 +10715,13 @@ void EmitPass::emitLoad(LoadInst *inst, Value *offset, ConstantInt *immOffset, C
1072410715
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
1072510716

1072610717
emitLSCVectorLoad(inst, inst->getPointerOperand(),
10727-
offset, immOffset, immScale, flipVarOffsetSign, cacheOpts, addrSpace
10718+
offset, immOffset, immScale, cacheOpts, addrSpace
1072810719
);
1072910720
return;
1073010721
}
1073110722
IGC_ASSERT_MESSAGE(immScale ? immScale->getSExtValue() == 1 : true, "Immediate Scale not supported on non-LSC path!");
1073210723

10733-
emitVectorLoad(inst, offset, immOffset, flipVarOffsetSign);
10724+
emitVectorLoad(inst, offset, immOffset);
1073410725
}
1073510726

1073610727
void EmitPass::emitPredicatedLoad(Instruction *inst) {
@@ -10745,7 +10736,7 @@ void EmitPass::emitPredicatedLoad(Instruction *inst) {
1074510736
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
1074610737

1074710738
emitLSCVectorLoad(inst, offset,
10748-
offset, nullptr, nullptr, false, cacheOpts, addrSpace
10739+
offset, nullptr, nullptr, cacheOpts, addrSpace
1074910740
);
1075010741
}
1075110742

@@ -11782,7 +11773,7 @@ void EmitPass::emitSymbolRelocation(Function &F) {
1178211773
}
1178311774

1178411775
void EmitPass::emitStoreRawIndexed(StoreRawIntrinsic *inst, Value *varOffset, ConstantInt *immScale,
11785-
ConstantInt *immOffset, bool flipVarOffsetSign) {
11776+
ConstantInt *immOffset) {
1178611777
Value *pBufPtr = inst->getResourceValue();
1178711778
Value *pValToStore = inst->getStoreValue();
1178811779

@@ -11793,8 +11784,8 @@ void EmitPass::emitStoreRawIndexed(StoreRawIntrinsic *inst, Value *varOffset, Co
1179311784

1179411785
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromMetadata(inst, false);
1179511786
emitLSCVectorStore(pBufPtr,
11796-
varOffset, immOffset, immScale, flipVarOffsetSign, pValToStore, inst->getParent(), cacheOpts,
11797-
inst->getAlignment(), false, addrSpace
11787+
varOffset, immOffset, immScale, pValToStore, inst->getParent(), cacheOpts, inst->getAlignment(),
11788+
false, addrSpace
1179811789
);
1179911790
return;
1180011791
}
@@ -11919,21 +11910,20 @@ void EmitPass::emitStore3DInner(Value *pllValToStore, Value *pllDstPtr, Value *p
1191911910
}
1192011911
}
1192111912

11922-
void EmitPass::emitStore(StoreInst *inst, Value *varOffset, ConstantInt *immOffset, ConstantInt *immScale,
11923-
bool flipVarOffsetSign
11913+
void EmitPass::emitStore(StoreInst *inst, Value *varOffset, ConstantInt *immOffset, ConstantInt *immScale
1192411914
) {
1192511915
if (shouldGenerateLSC(inst)) {
1192611916
LSC_DOC_ADDR_SPACE addrSpace = m_pCtx->getUserAddrSpaceMD().Get(inst);
1192711917

1192811918
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromMetadata(inst, false);
1192911919
emitLSCVectorStore(inst->getPointerOperand(),
11930-
varOffset, immOffset, immScale, flipVarOffsetSign, inst->getValueOperand(), inst->getParent(),
11931-
cacheOpts, IGCLLVM::getAlignmentValue(inst), inst->getMetadata("enable.vmask"), addrSpace
11920+
varOffset, immOffset, immScale, inst->getValueOperand(), inst->getParent(), cacheOpts,
11921+
IGCLLVM::getAlignmentValue(inst), inst->getMetadata("enable.vmask"), addrSpace
1193211922
);
1193311923
return;
1193411924
}
1193511925
IGC_ASSERT_MESSAGE(immScale ? immScale->getSExtValue() == 1 : true, "Immediate Scale not supported on non-LSC path!");
11936-
emitVectorStore(inst, varOffset, immOffset, flipVarOffsetSign);
11926+
emitVectorStore(inst, varOffset, immOffset);
1193711927
}
1193811928

1193911929
void EmitPass::emitPredicatedStore(Instruction *inst) {
@@ -11946,8 +11936,7 @@ void EmitPass::emitPredicatedStore(Instruction *inst) {
1194611936
LSC_CACHE_OPTS cacheOpts = translateLSCCacheControlsFromMetadata(inst, false);
1194711937

1194811938
emitLSCVectorStore(inst->getOperand(0),
11949-
inst->getOperand(0), nullptr, nullptr, false /*flipVarOffsetSign*/, inst->getOperand(1),
11950-
inst->getParent(), cacheOpts,
11939+
inst->getOperand(0), nullptr, nullptr, inst->getOperand(1), inst->getParent(), cacheOpts,
1195111940
cast<ConstantInt>(inst->getOperand(2))->getZExtValue(), // alignment
1195211941
inst->getMetadata("enable.vmask"), addrSpace
1195311942
,
@@ -14640,7 +14629,7 @@ CVariable *EmitPass::UnpackOrBroadcastIfUniform(CVariable *pVar) {
1464014629
}
1464114630

1464214631
void EmitPass::emitAtomicRaw(llvm::GenIntrinsicInst *pInst, Value *dstAddr, ConstantInt *immOffset,
14643-
ConstantInt *immScale, bool flipVarOffsetSign
14632+
ConstantInt *immScale
1464414633
) {
1464514634
ForceDMask();
1464614635
// Currently, Dword Atomics can be called by matching 2 intrinsics. One is the
@@ -14714,13 +14703,6 @@ void EmitPass::emitAtomicRaw(llvm::GenIntrinsicInst *pInst, Value *dstAddr, Cons
1471414703

1471514704
// Dst address in bytes.
1471614705
CVariable *pDstAddr = GetSymbol(dstAddr);
14717-
if (flipVarOffsetSign) {
14718-
CVariable *eNegBase = m_currShader->GetNewVariable(pDstAddr, CName(pDstAddr->getName(), "Neg"));
14719-
m_encoder->SetSrcModifier(0, EMOD_NEG);
14720-
m_encoder->Copy(eNegBase, pDstAddr); // MOV with -src modifier
14721-
m_encoder->Push();
14722-
pDstAddr = eNegBase;
14723-
}
1472414706

1472514707

1472614708
PointerType *PtrTy = dyn_cast<PointerType>(dstAddr->getType());
@@ -16642,7 +16624,7 @@ void EmitPass::emitFastClearSend(llvm::Instruction *pInst) {
1664216624
m_encoder->Push();
1664316625
}
1664416626

16645-
void EmitPass::emitVectorLoad(LoadInst *inst, Value *offset, ConstantInt *immOffset, bool flipVarOffsetSign) {
16627+
void EmitPass::emitVectorLoad(LoadInst *inst, Value *offset, ConstantInt *immOffset) {
1664616628
int immOffsetInt = 0;
1664716629
if (immOffset)
1664816630
immOffsetInt = static_cast<int>(immOffset->getSExtValue());
@@ -16656,13 +16638,6 @@ void EmitPass::emitVectorLoad(LoadInst *inst, Value *offset, ConstantInt *immOff
1665616638
// eOffset is in bytes
1665716639
// offset corresponds to Int2Ptr operand obtained during pattern matching
1665816640
CVariable *eOffset = GetSymbol(immOffset ? offset : Ptr);
16659-
if (flipVarOffsetSign) {
16660-
CVariable *eNegOffset = m_currShader->GetNewVariable(eOffset, CName(eOffset->getName(), "Neg"));
16661-
m_encoder->SetSrcModifier(0, EMOD_NEG);
16662-
m_encoder->Copy(eNegOffset, eOffset); // MOV with -src modifier
16663-
m_encoder->Push();
16664-
eOffset = eNegOffset;
16665-
}
1666616641
if (useA32) {
1666716642
eOffset = TruncatePointer(eOffset);
1666816643
}
@@ -17101,7 +17076,7 @@ void EmitPass::emitVectorLoad(LoadInst *inst, Value *offset, ConstantInt *immOff
1710117076
}
1710217077
}
1710317078

17104-
void EmitPass::emitVectorStore(StoreInst *inst, Value *offset, ConstantInt *immOffset, bool flipVarOffsetSign) {
17079+
void EmitPass::emitVectorStore(StoreInst *inst, Value *offset, ConstantInt *immOffset) {
1710517080
int immOffsetInt = 0;
1710617081
if (immOffset)
1710717082
immOffsetInt = static_cast<int>(immOffset->getSExtValue());
@@ -17118,13 +17093,6 @@ void EmitPass::emitVectorStore(StoreInst *inst, Value *offset, ConstantInt *immO
1711817093
// eOffset is in bytes
1711917094
// offset corresponds to Int2Ptr operand obtained during pattern matching
1712017095
CVariable *eOffset = GetSymbol(immOffset ? offset : Ptr);
17121-
if (flipVarOffsetSign) {
17122-
CVariable *eNegOffset = m_currShader->GetNewVariable(eOffset, CName(eOffset->getName(), "Neg"));
17123-
m_encoder->SetSrcModifier(0, EMOD_NEG);
17124-
m_encoder->Copy(eNegOffset, eOffset); // MOV with -src modifier
17125-
m_encoder->Push();
17126-
eOffset = eNegOffset;
17127-
}
1712817096
bool useA32 = !isA64Ptr(ptrType, m_currShader->GetContext());
1712917097
if (useA32) {
1713017098
eOffset = TruncatePointer(eOffset);
@@ -17799,7 +17767,7 @@ void EmitPass::emitLSCVectorLoad_uniform(LSC_CACHE_OPTS CacheOpts, bool UseA32,
1779917767

1780017768
void EmitPass::emitLSCVectorLoad(Instruction *inst, Value *Ptr,
1780117769
Value *varOffset, ConstantInt *immOffset, ConstantInt *immScale,
17802-
bool flipVarOffsetSign, LSC_CACHE_OPTS cacheOpts, LSC_DOC_ADDR_SPACE addrSpace
17770+
LSC_CACHE_OPTS cacheOpts, LSC_DOC_ADDR_SPACE addrSpace
1780317771
) {
1780417772

1780517773
bool predicatedLoad = false;
@@ -17829,13 +17797,6 @@ void EmitPass::emitLSCVectorLoad(Instruction *inst, Value *Ptr,
1782917797
// eOffset is in bytes
1783017798
// offset corresponds to Int2Ptr operand obtained during pattern matching
1783117799
CVariable *eOffset = GetSymbol(varOffset);
17832-
if (flipVarOffsetSign) {
17833-
CVariable *eNegOffset = m_currShader->GetNewVariable(eOffset, CName(eOffset->getName(), "Neg"));
17834-
m_encoder->SetSrcModifier(0, EMOD_NEG);
17835-
m_encoder->Copy(eNegOffset, eOffset); // MOV with -src modifier
17836-
m_encoder->Push();
17837-
eOffset = eNegOffset;
17838-
}
1783917800
if (useA32) {
1784017801
eOffset = TruncatePointer(eOffset);
1784117802
}
@@ -18187,9 +18148,9 @@ void EmitPass::emitLSCVectorStore_uniform(LSC_CACHE_OPTS CacheOpts, bool UseA32,
1818718148
}
1818818149

1818918150
void EmitPass::emitLSCVectorStore(Value *Ptr,
18190-
Value *varOffset, ConstantInt *immOffset, ConstantInt *immScale,
18191-
bool flipVarOffsetSign, Value *storedVal, BasicBlock *BB, LSC_CACHE_OPTS cacheOpts,
18192-
alignment_t align, bool dontForceDmask, LSC_DOC_ADDR_SPACE addrSpace
18151+
Value *varOffset, ConstantInt *immOffset, ConstantInt *immScale, Value *storedVal,
18152+
BasicBlock *BB, LSC_CACHE_OPTS cacheOpts, alignment_t align, bool dontForceDmask,
18153+
LSC_DOC_ADDR_SPACE addrSpace
1819318154
,
1819418155
Value *predicate) {
1819518156

@@ -18210,13 +18171,6 @@ void EmitPass::emitLSCVectorStore(Value *Ptr,
1821018171

1821118172
// offset corresponds to Int2Ptr operand obtained during pattern matching
1821218173
CVariable *eOffset = GetSymbol(varOffset);
18213-
if (flipVarOffsetSign) {
18214-
CVariable *eNegOffset = m_currShader->GetNewVariable(eOffset, CName(eOffset->getName(), "Neg"));
18215-
m_encoder->SetSrcModifier(0, EMOD_NEG);
18216-
m_encoder->Copy(eNegOffset, eOffset); // MOV with -src modifier
18217-
m_encoder->Push();
18218-
eOffset = eNegOffset;
18219-
}
1822018174
bool useA32 = !isA64Ptr(ptrType, m_currShader->GetContext());
1822118175
LSC_ADDR_SIZE addrSize = useA32 ? LSC_ADDR_SIZE_32b : LSC_ADDR_SIZE_64b;
1822218176
if (useA32) {

0 commit comments

Comments
 (0)