[PATCH] D125639: [NVPTX] Enable AtomicExpandPass for NVPTX
Shilei Tian via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 15 11:23:48 PDT 2022
tianshilei1992 created this revision.
tianshilei1992 added reviewers: jdoerfert, tra.
Herald added subscribers: mattd, gchakrabarti, asavonic, hiraditya, jholewinski.
Herald added a project: All.
tianshilei1992 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch enables `AtomicExpandPass` for NVPTX, making preparation for
the `atomicrmw` expansion later.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D125639
Files:
llvm/lib/CodeGen/AtomicExpandPass.cpp
llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
Index: llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
+++ llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp
@@ -330,6 +330,8 @@
addStraightLineScalarOptimizationPasses();
}
+ addPass(createAtomicExpandPass());
+
// === LSR and other generic IR passes ===
TargetPassConfig::addIRPasses();
// EarlyCSE is not always strong enough to clean up what LSR produces. For
Index: llvm/lib/CodeGen/AtomicExpandPass.cpp
===================================================================
--- llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -254,27 +254,33 @@
}
if (LI) {
- if (LI->getType()->isFloatingPointTy()) {
- // TODO: add a TLI hook to control this so that each target can
- // convert to lowering the original type one at a time.
- LI = convertAtomicLoadToIntegerType(LI);
- assert(LI->getType()->isIntegerTy() && "invariant broken");
- MadeChange = true;
- }
+ if (TLI->shouldExpandAtomicLoadInIR(LI) !=
+ TargetLoweringBase::AtomicExpansionKind::None) {
+ if (LI->getType()->isFloatingPointTy()) {
+ // TODO: add a TLI hook to control this so that each target can
+ // convert to lowering the original type one at a time.
+ LI = convertAtomicLoadToIntegerType(LI);
+ assert(LI->getType()->isIntegerTy() && "invariant broken");
+ MadeChange = true;
+ }
- MadeChange |= tryExpandAtomicLoad(LI);
+ MadeChange |= tryExpandAtomicLoad(LI);
+ }
} else if (SI) {
- if (SI->getValueOperand()->getType()->isFloatingPointTy()) {
- // TODO: add a TLI hook to control this so that each target can
- // convert to lowering the original type one at a time.
- SI = convertAtomicStoreToIntegerType(SI);
- assert(SI->getValueOperand()->getType()->isIntegerTy() &&
- "invariant broken");
- MadeChange = true;
- }
+ if (TLI->shouldExpandAtomicStoreInIR(SI) !=
+ TargetLoweringBase::AtomicExpansionKind::None) {
+ if (SI->getValueOperand()->getType()->isFloatingPointTy()) {
+ // TODO: add a TLI hook to control this so that each target can
+ // convert to lowering the original type one at a time.
+ SI = convertAtomicStoreToIntegerType(SI);
+ assert(SI->getValueOperand()->getType()->isIntegerTy() &&
+ "invariant broken");
+ MadeChange = true;
+ }
- if (tryExpandAtomicStore(SI))
- MadeChange = true;
+ if (tryExpandAtomicStore(SI))
+ MadeChange = true;
+ }
} else if (RMWI) {
// There are two different ways of expanding RMW instructions:
// - into a load if it is idempotent
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125639.429550.patch
Type: text/x-patch
Size: 2879 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220515/bfcdf2f0/attachment.bin>
More information about the llvm-commits
mailing list