Skip to content

Commit 7aa6c62

Browse files
authored
[PowecPC] Hint branch bne- for atomic operation after the store-conditional (llvm#152529)
The branches emitted for atomic operations after the store-conditional are currently not hinted, even though they should be. According to the Power10 Processor Chip User’s Manual: ` “Without static prediction, if the lock is not acquired in the first iteration, the branch history mechanism works to update the prediction to predict taken; that is, predict lock acquisition failure and cause more lwarx traffic for the next iteration.”` This patch addresses the issue by adding explicit branch hints for atomic operations after the store-conditional.
1 parent bffdf0b commit 7aa6c62

File tree

8 files changed

+766
-764
lines changed

8 files changed

+766
-764
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13092,7 +13092,9 @@ PPCTargetLowering::EmitAtomicBinary(MachineInstr &MI, MachineBasicBlock *BB,
1309213092
BuildMI(BB, dl, TII->get(StoreMnemonic))
1309313093
.addReg(TmpReg).addReg(ptrA).addReg(ptrB);
1309413094
BuildMI(BB, dl, TII->get(PPC::BCC))
13095-
.addImm(PPC::PRED_NE).addReg(PPC::CR0).addMBB(loopMBB);
13095+
.addImm(PPC::PRED_NE_MINUS)
13096+
.addReg(PPC::CR0)
13097+
.addMBB(loopMBB);
1309613098
BB->addSuccessor(loopMBB);
1309713099
BB->addSuccessor(exitMBB);
1309813100

@@ -13350,7 +13352,7 @@ MachineBasicBlock *PPCTargetLowering::EmitPartwordAtomicBinary(
1335013352
.addReg(ZeroReg)
1335113353
.addReg(PtrReg);
1335213354
BuildMI(BB, dl, TII->get(PPC::BCC))
13353-
.addImm(PPC::PRED_NE)
13355+
.addImm(PPC::PRED_NE_MINUS)
1335413356
.addReg(PPC::CR0)
1335513357
.addMBB(loopMBB);
1335613358
BB->addSuccessor(loopMBB);
@@ -14181,7 +14183,7 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
1418114183
.addReg(dest)
1418214184
.addReg(oldval);
1418314185
BuildMI(BB, dl, TII->get(PPC::BCC))
14184-
.addImm(PPC::PRED_NE)
14186+
.addImm(PPC::PRED_NE_MINUS)
1418514187
.addReg(CrReg)
1418614188
.addMBB(exitMBB);
1418714189
BB->addSuccessor(loop2MBB);
@@ -14193,7 +14195,7 @@ PPCTargetLowering::EmitInstrWithCustomInserter(MachineInstr &MI,
1419314195
.addReg(ptrA)
1419414196
.addReg(ptrB);
1419514197
BuildMI(BB, dl, TII->get(PPC::BCC))
14196-
.addImm(PPC::PRED_NE)
14198+
.addImm(PPC::PRED_NE_MINUS)
1419714199
.addReg(PPC::CR0)
1419814200
.addMBB(loop1MBB);
1419914201
BuildMI(BB, dl, TII->get(PPC::B)).addMBB(exitMBB);

0 commit comments

Comments
 (0)