@@ -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,
@@ -2528,9 +2526,6 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
2528
2526
if (IsVolatile) {
2529
2527
Changed |= setScope (MI, AMDGPU::CPol::SCOPE_SYS);
2530
2528
2531
- if (Op == SIMemOp::STORE)
2532
- Changed |= insertWaitsBeforeSystemScopeStore (MI);
2533
-
2534
2529
// Ensure operation has completed at system scope to cause all volatile
2535
2530
// operations to be visible outside the program in a global order. Do not
2536
2531
// request cross address space as only the global address space can be
@@ -2543,9 +2538,8 @@ bool SIGfx12CacheControl::enableVolatileAndOrNonTemporal(
2543
2538
return Changed;
2544
2539
}
2545
2540
2546
- bool SIGfx12CacheControl::finalizeStore (MachineBasicBlock::iterator &MI,
2547
- bool Atomic) const {
2548
- MachineOperand *CPol = TII->getNamedOperand (*MI, OpName::cpol);
2541
+ bool SIGfx12CacheControl::finalizeStore (MachineInstr &MI, bool Atomic) const {
2542
+ MachineOperand *CPol = TII->getNamedOperand (MI, OpName::cpol);
2549
2543
if (!CPol)
2550
2544
return false ;
2551
2545
@@ -2560,7 +2554,7 @@ bool SIGfx12CacheControl::finalizeStore(MachineBasicBlock::iterator &MI,
2560
2554
2561
2555
// GFX12.5 only: Require SCOPE_SE on stores that may hit the scratch address
2562
2556
// space.
2563
- if (TII->mayAccessScratchThroughFlat (* MI) && Scope == CPol::SCOPE_CU)
2557
+ if (TII->mayAccessScratchThroughFlat (MI) && Scope == CPol::SCOPE_CU)
2564
2558
return setScope (MI, CPol::SCOPE_SE);
2565
2559
2566
2560
return false ;
@@ -2664,6 +2658,8 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2664
2658
assert (!MI->mayLoad () && MI->mayStore ());
2665
2659
2666
2660
bool Changed = false ;
2661
+ // FIXME: Necessary hack because iterator can lose track of the store.
2662
+ MachineInstr &StoreMI = *MI;
2667
2663
2668
2664
if (MOI.isAtomic ()) {
2669
2665
if (MOI.getOrdering () == AtomicOrdering::Monotonic ||
@@ -2680,7 +2676,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2680
2676
MOI.getIsCrossAddressSpaceOrdering (),
2681
2677
Position::BEFORE);
2682
2678
2683
- Changed |= CC->finalizeStore (MI , /* Atomic=*/ true );
2679
+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ true );
2684
2680
return Changed;
2685
2681
}
2686
2682
@@ -2693,7 +2689,7 @@ bool SIMemoryLegalizer::expandStore(const SIMemOpInfo &MOI,
2693
2689
2694
2690
// GFX12 specific, scope(desired coherence domain in cache hierarchy) is
2695
2691
// instruction field, do not confuse it with atomic scope.
2696
- Changed |= CC->finalizeStore (MI , /* Atomic=*/ false );
2692
+ Changed |= CC->finalizeStore (StoreMI , /* Atomic=*/ false );
2697
2693
return Changed;
2698
2694
}
2699
2695
0 commit comments