@@ -321,8 +321,7 @@ class SICacheControl {
321
321
bool IsNonTemporal,
322
322
bool IsLastUse = false ) const = 0;
323
323
324
- virtual bool finalizeStore (MachineBasicBlock::iterator &MI,
325
- bool Atomic) const {
324
+ virtual bool finalizeStore (MachineInstr &MI, bool Atomic) const {
326
325
return false ;
327
326
};
328
327
@@ -603,8 +602,7 @@ class SIGfx12CacheControl : public SIGfx11CacheControl {
603
602
bool IsVolatile, bool IsNonTemporal,
604
603
bool IsLastUse) const override ;
605
604
606
- bool finalizeStore (MachineBasicBlock::iterator &MI,
607
- bool Atomic) const override ;
605
+ bool finalizeStore (MachineInstr &MI, bool Atomic) const override ;
608
606
609
607
bool insertRelease (MachineBasicBlock::iterator &MI, SIAtomicScope Scope,
610
608
SIAtomicAddrSpace AddrSpace, bool IsCrossAddrSpaceOrdering,
@@ -2538,9 +2536,6 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
2538
2536
if (IsVolatile) {
2539
2537
Changed |= setScope (MI, AMDGPU::CPol::SCOPE_SYS);
2540
2538
2541
- if (Op == SIMemOp::STORE)
2542
- Changed |= insertWaitsBeforeSystemScopeStore (MI);
2543
-
2544
2539
// Ensure operation has completed at system scope to cause all volatile
2545
2540
// operations to be visible outside the program in a global order. Do not
2546
2541
// request cross address space as only the global address space can be
@@ -2553,9 +2548,8 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
2553
2548
return Changed;
2554
2549
}
2555
2550
2556
- bool SIGfx12CacheControl::finalizeStore (MachineBasicBlock::iterator &MI,
2557
- bool Atomic) const {
2558
- MachineOperand *CPol = TII->getNamedOperand (*MI, OpName::cpol);
2551
+ bool SIGfx12CacheControl::finalizeStore (MachineInstr &MI, bool Atomic) const {
2552
+ MachineOperand *CPol = TII->getNamedOperand (MI, OpName::cpol);
2559
2553
if (!CPol)
2560
2554
return false ;
2561
2555
@@ -2570,7 +2564,7 @@ bool SIGfx12CacheControl::finalizeStore(MachineBasicBlock::iterator &MI,
2570
2564
2571
2565
// GFX12.5 only: Require SCOPE_SE on stores that may hit the scratch address
2572
2566
// space.
2573
- if (TII->mayAccessScratchThroughFlat (* MI) && Scope == CPol::SCOPE_CU)
2567
+ if (TII->mayAccessScratchThroughFlat (MI) && Scope == CPol::SCOPE_CU)
2574
2568
return setScope (MI, CPol::SCOPE_SE);
2575
2569
2576
2570
return false ;
@@ -2674,6 +2668,8 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2674
2668
assert (!MI->mayLoad () && MI->mayStore ());
2675
2669
2676
2670
bool Changed = false ;
2671
+ // FIXME: Necessary hack because iterator can lose track of the store.
2672
+ MachineInstr &StoreMI = *MI;
2677
2673
2678
2674
if (MOI.isAtomic ()) {
2679
2675
if (MOI.getOrdering () == AtomicOrdering::Monotonic ||
@@ -2690,7 +2686,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2690
2686
MOI.getIsCrossAddressSpaceOrdering (),
2691
2687
Position::BEFORE);
2692
2688
2693
- Changed |= CC->finalizeStore (MI , /* Atomic=*/ true );
2689
+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ true );
2694
2690
return Changed;
2695
2691
}
2696
2692
@@ -2703,7 +2699,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2703
2699
2704
2700
// GFX12 specific, scope(desired coherence domain in cache hierarchy) is
2705
2701
// instruction field, do not confuse it with atomic scope.
2706
- Changed |= CC->finalizeStore (MI , /* Atomic=*/ false );
2702
+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ false );
2707
2703
return Changed;
2708
2704
}
2709
2705
0 commit comments