diff options
| author | Philip Reames <listmail@philipreames.com> | 2016-04-22 20:33:48 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2016-04-22 20:33:48 +0000 |
| commit | eedef73b633496ca52af265b472519f0e385a7d2 (patch) | |
| tree | 7bf4e6df908b6b48c02f6549c448f8ff4129c27c /llvm/lib | |
| parent | 629d12de70959f49f0b8f78eb9e6e217103a24c7 (diff) | |
| download | bcm5719-llvm-eedef73b633496ca52af265b472519f0e385a7d2.tar.gz bcm5719-llvm-eedef73b633496ca52af265b472519f0e385a7d2.zip | |
[unordered] Extend load/store type canonicalization to handle unordered operations
Extend the type canonicalization logic to work for unordered atomic loads and stores. Note that while this change itself is fairly simple and low risk, there's a reasonable chance this will expose problems in the backends by suddenly generating IR they wouldn't have seen before. Anything of this nature will be an existing bug in the backend (you could write an atomic float load), but this will definitely change the frequency with which such cases are encountered. If you see problems, feel free to revert this change, but please make sure you collect a test case.
llvm-svn: 267210
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp index 638ae85d230..aa72244463e 100644 --- a/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp +++ b/llvm/lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp @@ -327,6 +327,8 @@ static LoadInst *combineLoadToNewType(InstCombiner &IC, LoadInst &LI, Type *NewT LoadInst *NewLoad = IC.Builder->CreateAlignedLoad( IC.Builder->CreateBitCast(Ptr, NewTy->getPointerTo(AS)), LI.getAlignment(), LI.getName() + Suffix); + NewLoad->setAtomic(LI.getOrdering(), LI.getSynchScope()); + assert(!LI.isVolatile() && "volatile unhandled here"); MDBuilder MDB(NewLoad->getContext()); for (const auto &MDPair : MD) { unsigned ID = MDPair.first; @@ -399,6 +401,8 @@ static StoreInst *combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value StoreInst *NewStore = IC.Builder->CreateAlignedStore( V, IC.Builder->CreateBitCast(Ptr, V->getType()->getPointerTo(AS)), SI.getAlignment()); + NewStore->setAtomic(SI.getOrdering(), SI.getSynchScope()); + assert(!SI.isVolatile() && "volatile unhandled here"); for (const auto &MDPair : MD) { unsigned ID = MDPair.first; MDNode *N = MDPair.second; @@ -456,9 +460,9 @@ static StoreInst *combineStoreToNewValue(InstCombiner &IC, StoreInst &SI, Value /// later. However, it is risky in case some backend or other part of LLVM is /// relying on the exact type loaded to select appropriate atomic operations. static Instruction *combineLoadToOperationType(InstCombiner &IC, LoadInst &LI) { - // FIXME: We could probably with some care handle both volatile and atomic - // loads here but it isn't clear that this is important. - if (!LI.isSimple()) + // FIXME: We could probably with some care handle both volatile and ordered + // atomic loads here but it isn't clear that this is important. + if (!LI.isUnordered()) return nullptr; if (LI.use_empty()) @@ -892,6 +896,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { V1->setAtomic(LI.getOrdering(), LI.getSynchScope()); V2->setAlignment(Align); V2->setAtomic(LI.getOrdering(), LI.getSynchScope()); + assert(!LI.isVolatile() && "volatile unhandled here"); return SelectInst::Create(SI->getCondition(), V1, V2); } @@ -934,9 +939,9 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) { /// the store instruction as otherwise there is no way to signal whether it was /// combined or not: IC.EraseInstFromFunction returns a null pointer. static bool combineStoreToValueType(InstCombiner &IC, StoreInst &SI) { - // FIXME: We could probably with some care handle both volatile and atomic - // stores here but it isn't clear that this is important. - if (!SI.isSimple()) + // FIXME: We could probably with some care handle both volatile and ordered + // atomic stores here but it isn't clear that this is important. + if (!SI.isUnordered()) return false; Value *V = SI.getValueOperand(); |

